Just thought I would give a quick tutorial on remoteevents.
If we want to send a message to the server from the client we would first insert a remoteevent into replicatedstorage. Then in a local script, which does not have to be inside of the remoteevent (it could be in the starterGUI inside of a textButton) we would do the following:
local Button = script.Parent Button.MouseButton1Click:Connect(function() game.ReplicatedStorage.RemoteEvent:FireServer(script.Parent.Name) end)
For the purpose of this tutorial, I am going to send the name of the TextButton to the server to show you how you can use parameters in RemteEvents. This script tells the RemoteEvent to tell the server we want to do something.
Next, create a new script into the workspace or ServerScriptService and do the following:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player,TextButtonName) --Anything here will run when the TextButton is clicked local Part = Instance.new('Part') Part.Name = 'TestPart' Part.Parent = game.Workspace print(TextButtonName) end)
The following script will make it so when the button is pressed, a new part will be created in the workspace. The reason for the player argument in the parameter is because Roblox automatically sends the player, therefore we must put it there. TextButtonName is what was sent from the local script (script.Parent.Name). 'TextButtonName' can be called anything.