I am trying to make a server script where if you stand on a part, an image label in another part will change to the image linked with the team.
I don’t know what I have done, but I think the problem is something to do with getting the player
I don’t know what to try in order to fix it.
local picture = script.parent.parent.Flag.BillboardGui.ImageLabel
local player = game.Players.LocalPlayer
script.Parent.Touched:Connect()
if player.TeamColor == "White" then
picture.Image = "rbxassetid://108835069"
end
if player.TeamColor == "Dark blue" then
picture.Image = "rbxassetid://2884889387"
end
end)
if player.TeamColor == BrickColor.new("Dark blue")
You could also use elseif.
Edit
If it’s a server script, then you can’t use localplayer.
local Players = game:GetService("Players")
local picture = script.parent.parent.Flag.BillboardGui.ImageLabel
script.Parent.Touched:Connect(function(hit)
local player = Players:GetPlayerFromCharacter(hit.Parent)
if not player then
return
end
if player.TeamColor == BrickColor.new("White") then
picture.Image = "rbxassetid://108835069"
elseif player.TeamColor == BrickColor.new("Dark blue") then
picture.Image = "rbxassetid://2884889387"
end
end)