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

Player cant open door when click-detector pressed?

Asked by 4 years ago

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

Log in to vote
2
Answered by
Leamir 3138 Moderation Voter Community Moderator
4 years ago

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)

Ad

Answer this question