im working on a capture point system and it’s detecting when a player touchs the block and checks their team to change it to the proper color.
Video:
The problem is that It detects when I step on it and it changes color to my proper team
But when I change my team it wont change the color,
CODE:
local objective = script.Parent
objective.Touched:Connect(function(hit)
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
if player.Team.Name == "British" then
objective.Color = Color3.fromRGB(128,0,0)
elseif player.Team.Name == "Germany" then
objective.Color = Color3.fromRGB(0, 92, 138)
end
end
end)
if player then
if player.Team.Name == "British" then
objective.Color = Color3.fromRGB(128,0,0)
end
if player.Team.Name == "Germany" then
objective.Color = Color3.fromRGB(0, 92, 138)
end
end
end)
edit: dumb forum took tab as action instead of space
Are you sure you’re changing your team on the server and not just the client? Your code should work the way it is. It’s a common mistake, especially if you’re playtesting in studio.