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

How would I change a value from a gui button?

Asked by 3 years ago

I've been stumped for hours now, I've tried using remote events but It changes a value for everyone. The value is located inside of the player's character, I want it so when I click the gui button it'll change the value. How would I go about doing this?

GUI Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local plr = game.Players.LocalPlayer
local Eventt = plr.Character.PBUEVENT
local btn = script.Parent

btn.MouseButton1Click:Connect(function(plr)
print("Clicked")
Eventt:FireServer(plr)
end)

Server Script

local Event = script.Parent.PBUEVENT

Event.OnServerEvent:Connect(function(player)
    print("Fired")
    player.Character.Jersey.PlayerEngine.CatchType.Value = "PBU"
end)

1 answer

Log in to vote
0
Answered by 3 years ago

When you use :FireServer(), you don’t need to put the player instance inside the parameters.

You would need to:

—Server script
local event

event.OnServerEvent:Connect(function(plr)

print(“fired event from client “..plr.Name

end)

—Local script

local button
local event

button.Activated:Connect(function()
event:FireServer()
end)

Ad

Answer this question