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

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

Asked by 3 years ago
Edited 3 years ago

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.

0
I think the Issue is you need to use remote functions instead of remote events. Dragon_meck 15 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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

Ad

Answer this question