Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.