Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

The colors for my GUI not changing? (script not working)

I have been trying to make a script that when touching a brick it changes a Guis color (for everyone) to the color of the player who touches the bricks team, a fix would be very much appreciated.

team = script.Parent 
flag = script.Parent.Parent.Flag
pole = script.Parent.Parent.Pole
teamGui = game.StarterGui.ScreenGui.TextBox

function onTouch(hit) 
local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
if user ~= nil then
team.BrickColor = user.TeamColor 
flag.BrickColor = user.TeamColor
teamGui.BackgroundColor3 = user.TeamColor
end 

script.Parent.Touched:connect(onTouch) 

1 comment

0

Guis arent replicated to the server

1 answer

✓ Accepted answer
team = script.Parent
flag = script.Parent.Parent.Flag
pole = script.Parent.Parent.Pole

function onTouch(hit)
	local user = game.Players:GetPlayerFromCharacter(hit.Parent) 
	if user ~= nil then
		team.BrickColor = user.TeamColor
		flag.BrickColor = user.TeamColor
		-- Cycle through every player and change their gui color
		for _, player in pairs(game.Players:GetPlayers()) do
			player.PlayerGui.ScreenGui.TextBox.BackgroundColor3 = user.TeamColor.Color
		end
	end
end 

script.Parent.Touched:connect(onTouch)

1 comment

0

Thanks vector

This discussion is preserved as it was. New answers, comments, and votes are closed.