Answered by
7 years ago Edited 7 years ago
So, first you should have the model you want to clone inside of game.ReplicatedStorage. Don't use lighting, since that isn't meant for storing stuff, obviously. You also shouldn't use ServerStorage, since we're going to be coding in a localscript.
First, create a "RemoteEvent" and put it in ReplicatedStorage. RemoteEvent is what's used to have the server communicate with the client. (and vise versa)
Next, put this in a ServerScript inside ServerScriptService (Never put normal scripts in workspace)
01 | local model = game.ReplicatedStorage.name |
03 | function spawnModelForPlr(plr) |
04 | local character = plr.Character |
05 | local newModel = model:Clone() |
06 | newModel.Parent = game.Workspace |
07 | newModel:MoveTo((character.Head.CFrame * CFrame.new( 0 , 0 , - 10 )).p) |
10 | game.ReplicatedStorage.RemoteEvent.OnServerEvent:connect(spawnModelForPlr) |
Next, put a LocalScript inside of the TextButton you've created. Inside it, have this code:
1 | local button = script.Parent |
3 | button.MouseButton 1 Click:connect( function () |
4 | game.ReplicatedStorage.RemoteEvent:FireServer() |