So I have 2 scripts a script and local so what I tried to make is that in the server, it will change a value. In the client, I want it to change a color of a button when pressed. The server script doesn't change the values . The local script function doesn't run. Why?

Note: Just realized I typed formRGB() I changed it so just ignore it.

Script

script.Parent.MouseButton1Click:Connect(function()
	local plr = script.Parent.Parent.Parent.Parent
	local event = game.ReplicatedStorage.DuelColor
	if plr.InDuel.Value == true then
		plr.InDuel.Value = false
		event:FireClient(plr,1,script.Parent)
	end
	if plr.InDuel.Value == false then
		plr.InDuel.Value = true
		event:FireClient(plr,2,script.Parent)
	end
end)

Local Script

local event = game.ReplicatedStorage.DuelColor
event.OnClientEvent:Connect(function(number,gui)
	print("Yay!")
	if number == 1 then
		gui.BackgroundColor3 = Color3.formRGB(255,0,0)
	end
	if number == 2 then
		gui.BackgroundColor3 = Color3.formRGB(0,255,0)
	end
end)
Edit: fixed font of the text, it was too big.

3 comments

0

MouseButton1Click is an event of a GuiButton. This should be used in a local script so there isn't a need for a RemoteEvent here.

0

maybe you mean to use ClickDetector.MouseClick instead of MouseButton1Click?

0

i have a question too, how did you make that text smaller? xd