You cannot access localplayer from a server script. Here is what you can do alternatively:
- Make server script
- Make a remote event
- Fire the remote event with the password as the arg
- Put this in your server script:
local remoteevent = -- reference remote event path here
local correctpass = 2323
remoteevent.OnServerEvent:Connect(function(p, pass)
-- p is player and pass is the password the user entered
if tonumber(pass) == correctpass then
-- User entered correct pass so open the door
else
p.Character.Humanoid.Health = 0
end
end)
And finally, fire the remote event from the local script just like this:
local remoteevent = -- reference remote event path here
local userinput = -- get the password the user entered here
remoteevent:FireServer(userinput)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…