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
3 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.

local rank = 4
local groupID = 6609636
script.Parent.Touched:connect(function(hit)
    if (hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name)) then
        if (game.Players[hit.Parent.Name]:IsInGroup(groupID) and game.Players[hit.Parent.Name]:GetRankInGroup(groupID) >= rank) then
            script.Parent.CanCollide = false
            script.Parent.Transparency = .9
            wait(1)
            script.Parent.CanCollide = true
            script.Parent.Transparency = 0
        else
            script.Parent.CanCollide = true
        end
    end
end)

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 3 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.

local door = workspace:FindFirstChild("Door",true) --Change this to the name of the door
local rank = 4
local groupID = 6609636
door.Touched:connect(function(hit)  
    if hit and hit.Parent and game.Players:FindFirstChild(hit.Parent.Name) then
        if game.Players[hit.Parent.Name]:IsInGroup(groupID) and game.Players[hit.Parent.Name]:GetRankInGroup(groupID) >= rank then
            door.CanCollide = false
            door.Transparency = .9
        wait(1)
            door.CanCollide = true
            door.Transparency = 0
    else
        door.CanCollide = true
        end
    end
end)
Ad

Answer this question