Why isn't Model:Clone() working?

I am in the process of making a Host Ui thing for my friend but when I finished my script that clones from replicated storage to workspace by clicking a button it seems that it dosen’t work, am I missing anything in this script?

Button = script.Parent.Parent.StarterGui.HostUi.HostChoose.PianoButton

Button.MouseButton1Click:Connect(function() -- Activates when you click a button
	game.ReplicatedStorage.WallJumps:Clone().Parent = game.Workspace
end)

Any help would be very much appreciated

Try doing it like this:

Button = script.Parent.Parent.StarterGui.HostUi.HostChoose.PianoButton

Button.MouseButton1Click:Connect(function() -- Activates when you click a button
	local clone = game.ReplicatedStorage.WallJumps:Clone()
    clone.Parent = game.Workspace
end) 
1 Like

Well it didn’t work but I also forgot to add that the script is in ServerScriptService

It doesn’t work because it’s connected to a button in StarterGui… The PlayerGui is where you want to connect to.

1 Like

It works, thanks my man I really appreciate it!

Create a local script under the button and put this in it:

local button = script.Parent

button.MouseButton1Click:Connect(function()
  game.ReplicatedStorage.YourEventNameHere:FireServer()
end)

Also create a Remote Event in ReplicatedStorage.

Then create a script under ServerScriptService.

game.ReplicatedStorage.YourEventNameHere.OnServerEvent:Connect(function()
  local clone = game.ReplicatedStorage.Walljumps:Clone()
  clone.Parent = game.Workspace
end)

Then you should be fine. Tell me when there are errors.
Also, if you don’t know how remote events work, you can find a link here.

Hey, you’d probably best go with @vycVascense’s suggestion. Remotes are great, and if you just modified your current script to a single Players PlayerGui, then it won’t work for anybody else.

1 Like