I'm Trying to check if the player is in a specific team and has a the value of X then they could use the button can anyone help
local CoinWorth = 50 Button.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local Plr = workspace[hit.Parent.Name] local Player = game.Players:GetPlayerFromCharacter(Plr) if Player.Team == "Red" and Player.leaderstats.Coins.Value >= CoinWorth then Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value - CoinWorth end end end)
Hello. Here I fixed your Script
and I added Debounce.
```
local CoinWorth = 50
local WaitTime = 5
local Debounce = false
function onHit(hit) if hit.Parent:FindFirstChild("Humanoid") then local PlayerCharacter = game.Workspace[hit.Parent.Name] local Player = game.Players:GetPlayerFromCharacter(PlayerCharacter) if Player.Team.Name == "Red" and Player.leaderstats.Coins.Value >= CoinWorth and Debounce == false then Debounce = true Player.leaderstats.Coins.Value = Player.leaderstats.Coins.Value - CoinWorth wait(WaitTime) Debounce = false end end end
script.Parent.Touched:Connect(onHit)
You tried to check player's team by player.Team == "Red". This is like you are trying to check a team name like this.
if game.Teams.Red == "Red"" then
print("True")
end
```
Which is incorrect.
You can do: if player.Team.Name == "Red"
or if player.Team == game.Teams.Red
.