So yeah, how do i do that??
How do i put a part out of serverstorage when a textbutton is touched in a gui?
1 answer
This is a complete request, which isn't allowed, but I'm feeling nice. In the future, please do not post questions without showing your clear attempt at solving the issue.
To accomplish this, we'll have to make use of a few things:
Remote Events, Local Scripts, Server Scripts, TextButtons
The following code will assume you have a ScreenGui in the StarterGui service with a TextButton inside it. The LocalScript will be inside the TextButton. Additionally, I'm assuming you have an instance in ServerStorage named Part.
--Local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local button = script.Parent
button.MouseButton1Click:Connect(function()
RemoteEvent:FireServer() --tell server to clone part into workspace
end)
Let's go through this line by line. First, we set up our variables. Our RemoteEvent variable is waiting for the server to add a remote event to ReplicatedStorage (see lines 5 and 6 of the next script). Our next variable, button, is the TextButton. When the player clicks this, the function connected to MouseButton1Click will be run. This tells the server to perform an action (line 8 of the Local script).
--Server script
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = Instance.new("RemoteEvent")
RemoteEvent.Parent = ReplicatedStorage
RemoteEvent.OnServerEvent:Connect(function(player) --first parameter is always the player that fired the event
if ServerStorage:FindFirstChild("Part") then
local part = ServerStorage.Part:Clone()
part.Parent = workspace
end
end)
In this script, we are creating the remote event in lines 5 and 6. This is what the client was waiting for previously. The function connected to OnServerEvent will be run once RemoteEvent:FireServer() is run in the Local script. Afterwards, we check if there is an object in ServerStorage named Part. If so, we create a clone of that and parent it to the workspace. Further reading is available below.
##Resources:
Remote Events and Functions
##Accept and upvote if this helps!
2 comments
Ok i am sorry i didnt know that wasn"t allowed
upvote if it helped
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Remote events.
Can i have an example, please?