hi, im trying to make it so when you press the button, it will activate an event. but when i press the button, nothing happens. (fyi, when i join the game im teamed another team, and i manually team myself to the brown coloured team afterwards)
local clickDetector = script.Parent.ClickDetector
local remoteevent = game.ReplicatedStorage.CannonPrep
debounce = false
local function onClicked(player)
if not debounce then
if player.TeamColor == BrickColor.new("Brown") then
print("passed check 1") --it does not print
debounce = true
script.Parent.Sound:Play()
remoteevent:FireServer()
wait(35)
debounce = false
end
end
end
clickDetector.MouseClick:Connect(onClicked)
Now, as for Scripts with RunContext set to Client, I believe they will run no matter where they are parented. Though I have never used normal scripts this way personally, so I could be wrong.
So you could either try changing the LocalScript to a normal script with RunContext set to Client, or, changing this to just a normal server script and changing the content of the script accordingly.