I’m having issues with player and its teams.
Im trying to make it when a player click on something the script check if its in a specific team but it keeps giving me the error; Team is not a valid member of Players “Players” .
Heres my code:
local C4Module = require(script.Parent:WaitForChild("C4Module"))
local Player = game:GetService("Players")
local Team = game:GetService("Teams")["Blue"]
script.Parent.ClickDetector.MouseClick:Connect(function(part)
if debounce == true then
debounce = false
if Player.Team == Team then
C4Module.c4_setup()
C4Module.explode()
wait(240)
C4Module.restore()
wait(180)
script.Parent.Cooldownlift2:Play()
script.Parent.SelectionBox.Color3 = Color3.fromRGB(255,0,0)
end
end
end)
You’re not comparing the player to the team - you’re comparing the Players service with a property Team (which it doesn’t have) to the Team variable. To fix this, you can add .LocalPlayer to your Player variable. (Assuming this is a LocalScript)
A click detector returns the player who clicked it - perhaps this is what you were tryna do? (Assuming this is a Script)
local C4Module = require(script.Parent:WaitForChild("C4Module"))
local Team = game:GetService("Teams")["Blue"]
local debounce = true
script.Parent.ClickDetector.MouseClick:Connect(function(Player)
if debounce == true then
debounce = false
if Player.Team == Team then
C4Module.c4_setup()
C4Module.explode()
wait(240)
C4Module.restore()
wait(180)
script.Parent.Cooldownlift2:Play()
script.Parent.SelectionBox.Color3 = Color3.fromRGB(255,0,0)
end
end
end)