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)
end)
and also u need to add a RemoteEvent in ReplicatedStorage
2 comments
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.
I do not understand.