✓ Accepted answer
In order to be able to do that upon a button click, you need to use Remote Events. Let me explain why.
If your script is a server script parented to a gui in StarterGui, it won't run when the gui is cloned, because the gui is cloned locally.
If your script is a localscript, it won't be able to access the ServerStorage.
Here's an example of what your scripts should look like:
Server script
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
Remote.OnServerEvent:Connect(function(plr)
local model = game:GetService("ServerStorage"):WaitForChild("FFA"):Clone()
model.Parent = workspace
model:SetPrimaryPartCFrame(CFrame.new())
end)
Localscript
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
script.Parent.MouseButton1Click:Connect(function()
Remote:FireServer()
end)
Note that it's an example. It's so that you get the idea of how it should work, and make your own code basing on it, along with some checks so for example exploiters cannot loop clone the model to workspace with the remote.
3 comments
is this in a local or server script?
you need to put the model in replicated storage so the client can access it.
Although the script is a bit clear,you should use Lua code blocks.