Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Personal Key -Door Key?-

Asked by
Axcur 0
8 years ago

How can I make a script that the key can go unlock the door and go to that only person. For an Example Billy came in the game and he owns a house. He hates when people come to his house when hes not there. He wants a key to only unlock the door and he can open.

2 answers

Log in to vote
0
Answered by
WVPII 5
8 years ago

Do you have any code? This is scripting helpers as opposed to scripting makers. But I'll give you the core mechanics in case you can code

local owner = "" -- This could be a string value, a numerical value (if the player has an ID key) or a 3rd part string

script.Parent.Touched:connect(function(hit)
    if hit.Parent.Name == owner then
        script.Parent.Transparency = 0.3
        script.Parent.CanCollide = false
        wait(.5)
        script.Parent.Transparency = 0
        script.Parent.CanCollide = true
    else
        local hum = hit.Parent:FindFirstChild("Humanoid")
        hum:TakeDamage(100)
end)
0
THANK YOU. This do work :D Axcur 0 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

one way is to make the door.cancollide = false when billy touches the door, but not when other players touch the door. you can do this by checking if the object that touches the door has billys name or his userId, and if it doesn't then nothing happens, but if it does then it changes the door cancollide property to false for a few seconds. you could then add a button on the inside of the house that billy can click to make the door cancollide = false so his friends can enter. then before he leaves the game he can lock it and noone else can enter until he unlocks it again.

Answer this question