Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago
Edited 6 years ago

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) 

0
Guis arent replicated to the server NexanianStudios 91 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
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)
0
Thanks vector Mick3700 2 — 6y
Ad

Answer this question