Im making a game where the player is in a marble, i have made a GUI that changes a StringValue, When the string value changes, the players marble color will also change, it works great, Only problem is when the players marble color changes, the other players cant see that it changed,
Here is the script inside the GUI,
local Plr = game.Players.LocalPlayer
local ColorHolder = Plr:WaitForChild("ColorHolder")
local Color = ColorHolder.Color
local Button = script.Parent
Button.MouseButton1Up:Connect(function()
Color.Value = "Red"
end)
Now Here is the script in StarterPlayerScripts,
local ColorHolder = Plr:WaitForChild("ColorHolder")
local Color = ColorHolder.Color
local Character = Plr.Character
local Ball = Character:WaitForChild("Part")
while true do
wait()
if Color.Value == "Red" then
Ball.BrickColor = BrickColor.new("Really red")
end
if Color.Value == "Blue" then
Ball.BrickColor = BrickColor.new("Really blue")
end
if Color.Value == "Pink" then
Ball.BrickColor = BrickColor.new("Pink")
end
Keep in mind they’re both Local Scripts,
And there’s a value in the player called “Color”
Next, create a Script in ServerScriptServce, and put that :
game:GetService("ReplicatedStorage").ChangeColor.OnServerEvent:Connect(function(player, color)
if color == "Red" then
player.Character:WaitForChild("Part").BrickColor = BrickColor.new("Really red")
elseif color == "Blue" then
player.Character:WaitForChild("Part").BrickColor = BrickColor.new("Really blue")
elseif color == "Pink" then
player.Character:WaitForChild("Part").BrickColor = BrickColor.new("Pink")
end
end)
Next, in your button, create a LocalScript and write that: