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

Execute Button for ServerSided scripts, how do i code it?

Asked by 2 years ago
Edited 2 years ago

how can i code an execute button for a serversided script executor? I was trying to teach my friends on how to use it so they dont ask me for a game that supports ServerSide scripts, and give them some.~~~~~~~~~~~~~~~~~ --1 thing I forgot to mention: I need the button to be used in a gui that can be used in EVERY game, all inside a MainModule. ~~~~~~~~~~~~~~~~~

3 answers

Log in to vote
0
Answered by 2 years ago

I do not understand fully what you mean. I don't know if you mean you want a button that will run a server-side script? I am very confused. If you do and you want to use GUI's, you can use events to send data to another script and then execute the function.

0
Yes, i need a button code that runs a script like an require in an textbox above the button. I have one currently, from an tutorial, but it wont work. liampokemonlover 0 — 2y
0
I do not understand. MarsSquirrel 10 — 2y
Ad
Log in to vote
0
Answered by 2 years ago

If you want to make a GUI Button that fires a event on the server and do something with that then add a Button and a local script inside it with this code:

local Button = script.Parent
local Player = game:GetService("Players").LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("Event")

Button.MouseButton1Click:Connect(function()
    Event:FireServer(Player)
end)

and add a Server script in ServerScriptService with this code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Event = ReplicatedStorage:WaitForChild("Event")

Event.OnServerEvent:Connect(function(Player)
    print("Event got fired by : "..Player.Name)
    -- do what ever u want
end)

and also u need to add a RemoteEvent in ReplicatedStorage

0
1 thing I forgot to mention: I need the button to be used in a gui that can be used in EVERY game, all inside a MainModule. liampokemonlover 0 — 2y
Log in to vote
0
Answered by 2 years ago
--1 thing I forgot to mention: I need the button to be used in a gui that can be used in EVERY game, all inside a MainModule.

Answer this question