Hello, I am making a simple keycard door and I would like it to only open for the person that opens it. I tried doing this by putting a local script inside of StarterPlayerScripts, here is the code:
local function onTouch(hit)
if hit.Parent.Name == "Visa" then
game.Workspace.BorderBlock.CanCollide = false
wait(2)
game.Workspace.BorderBlock.CanCollide = true
end
end
game.Workspace.BorderBlock.Touched:Connect(onTouch)
It works with this but it opens for all players.
Does anyone know how to help? Thank you for reading!
local Player = game.Players.Localplayer
local function onTouch(hit)
if hit.Parent.Name == "Visa" and hit.Parent.Parent.Name = Player.Name then
game.Workspace.BorderBlock.CanCollide = false
wait(2)
game.Workspace.BorderBlock.CanCollide = true
end
end
game.Workspace.BorderBlock.Touched:Connect(onTouch)
Take note i did this fast and untested.
And im guessing Hit.Parent is a tool.
I don’t think he’s looking to check it serverside.
Even tho “CanCollide” is not really requested to be checked serverside as it can be edited clientside.