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

[ANSWERED] GUI Button triggering remote event only works once?

I have a GUI button that when clicked, triggers a remote event to the server to change the color of the client's head on the avatar. Here is what is written in a local script:

local btn = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OvercookedEvent = ReplicatedStorage:WaitForChild("OvercookedEvent")
local plr = game.Players.LocalPlayer

btn.MouseButton1Click:Connect(function(plr)
	btn.Text = "EQUIPPED"
	btn.Parent.DefaultButton.Text = "EQUIP"
	btn.Parent.Undercookedbutton.Text = "EQUIP"
	btn.Parent.SweetPotatoButton.Text = "EQUIP"
	OvercookedEvent:FireServer(plr)
end)

Here is what is in a server script:

local btn = game.StarterGui.GameGUI.FriesMenu.OvercookedButton
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local OvercookedEvent = ReplicatedStorage:WaitForChild("OvercookedEvent")

OvercookedEvent.OnServerEvent:Connect(function(plr)
	local Character = plr.Character
	local bodyColors = Character:WaitForChild("Body Colors")
	bodyColors.HeadColor = BrickColor.new("Alder")
end)

This works, but it only does this once, meaning that when I click the GUI button, my avatar's head becomes alder, but then after I switch the head color back to normal using another button my game, this button no longer colors the head alder when clicked after the first time.

1 comment

0

I think the Issue is you need to use remote functions instead of remote events.

1 answer

I've fixed this myself. The issue was with other scripts that interacted with this situation. :)

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