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

Player cant open door when click-detector pressed?

im making a prison game, and the team "Staff" should be the only ones to open the door, however when i try this script it will not work, i am quite new to scripting so any explanations about what i did wrong will help lots aswell!

Other info = script.parent is a union Staff is correctly capitalized.

local ClickDetector = script.Parent.ClickDetector
local Team = game:GetService("Teams")
local Players = game:GetService("Players")

 ClickDetector.MouseClick:Connect(function(player)

	if player.Team == "Staff" then
		
		script.Parent.Transparency = 0.5
		script.Parent.CanCollide = false
		
		wait(2)
		
		script.Parent.Transparency = 0
		script.Parent.CanCollide = true
		
	end
end)

1 answer

✓ Accepted answer

Hello, pokemonzizzle8383!

You can't check objects with strings, you can check an object name with a string

local ClickDetector = script.Parent.ClickDetector
local Team = game:GetService("Teams")
local Players = game:GetService("Players")

 ClickDetector.MouseClick:Connect(function(player)

    if player.Team.Name == "Staff" then -- Or use player's team name, or player's team brickcolor

        script.Parent.Transparency = 0.5
        script.Parent.CanCollide = false

        wait(2)

        script.Parent.Transparency = 0
        script.Parent.CanCollide = true

    end
end)

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