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

How would I make a door that runs locally in Roblox?

Asked by
Comqts 6
4 years ago

So, when ever there is a rank door, and someone that is allowed opens it, then that allows others able to come in since the door is opened.

01local rank = 4
02local groupID = 6609636
03script.Parent.Touched:connect(function(hit)
04    if (hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name)) then
05        if (game.Players[hit.Parent.Name]:IsInGroup(groupID) and game.Players[hit.Parent.Name]:GetRankInGroup(groupID) >= rank) then
06            script.Parent.CanCollide = false
07            script.Parent.Transparency = .9
08            wait(1)
09            script.Parent.CanCollide = true
10            script.Parent.Transparency = 0
11        else
12            script.Parent.CanCollide = true
13        end
14    end
15end)

I also put the Local Script in the door seeing if that would work, but it didn't.

1 answer

Log in to vote
0
Answered by 4 years ago

The reason the code doesn't work is because local scripts don't run in workspace. I suggest to make a local script in StarterPlayerScripts and use that code.

01local door = workspace:FindFirstChild("Door",true) --Change this to the name of the door
02local rank = 4
03local groupID = 6609636
04door.Touched:connect(function(hit) 
05    if hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
06        if game.Players[hit.Parent.Name]:IsInGroup(groupID) and game.Players[hit.Parent.Name]:GetRankInGroup(groupID) >= rank then
07            door.CanCollide = false
08            door.Transparency = .9
09        wait(1)
10            door.CanCollide = true
11            door.Transparency = 0
12    else
13        door.CanCollide = true
14        end
15    end
16end)
Ad

Answer this question