Hey Devforum! I’m trying to maker a player overhead GUI change when a color is selected on the color wheel. So the Overhead GUI is working at first but when the player resets I don’t know how to bring back what they selected and only keep the color change to that client but show it to all clients or the server. The overhead GUI is stored in ReplicatedStorage.Gui.PlayerGui
Local Script:
local button = script.Parent
local LocalPlayer = game.Players.LocalPlayer
local ChangeName = game.ReplicatedStorage:WaitForChild("ChangeName")
local function triggerEvent(color)
ChangeName:FireServer(color)
end
local function onButtonActivated()
local Char = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local hum = Char:WaitForChild('HumanoidRootPart')
local num = script.Parent.Parent.Value.Value
hum.PlayerGui.PlayerTime.TextColor3 = num
triggerEvent(num)
script.Parent.Parent.Parent.ColourWheelGui.Enabled = false
end
button.Activated:Connect(onButtonActivated)
ServerScript:
local ChangeName = game.ReplicatedStorage:WaitForChild("ChangeName")
ChangeName.OnServerEvent:Connect(function(player, num)
local character = player.Character
if character then
character.HumanoidRootPart.PlayerGui.PlayerTime.TextColor3 = num
end
end)
I think I found my problem. The GUI gets added every time the character is added .CharacterAdded so when they reset a new gui is added into their HumanoidRootPart. I know this but I don’t know how to fix my issue, any help will work.
function giveGui(character) local player = game.Players:GetPlayerFromCharacter(character) local HumanoidRootPart = character.HumanoidRootPart if player ~= nil then local playerGui = game.ReplicatedStorage.Gui.PlayerGui:Clone() playerGui.Parent = HumanoidRootPart if HumanoidRootPart:FindFirstChild("Color3Value") and HumanoidRootPart:FindFirstChild("Color3Value").Value ~= {0, 0, 0} then playerGui.PlayerTime.TextColor3 = HumanoidRootPart.Color3Value.Value end end end
Same script different line: game.Players.PlayerAdded:Connect(function(player) timeGive()
local button = script.Parent
local LocalPlayer = game.Players.LocalPlayer
local Char = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local ChangeName = game.ReplicatedStorage:WaitForChild("ChangeName")
triggerEvent(script.Parent.Parent.Value.Value)
local function triggerEvent(color)
ChangeName:FireServer(color)
end
local function onButtonActivated()
local hum = Char:WaitForChild('HumanoidRootPart')
local num = script.Parent.Parent.Value.Value
hum.PlayerGui.PlayerTime.TextColor3 = num
triggerEvent(num)
script.Parent.Parent.Parent.ColourWheelGui.Enabled = false
end
button.Activated:Connect(onButtonActivated)
Try this, and make sure the ScreenGui which is called ColorWheelGui has the property ResetOnSpawn set to false.