Local Script:
01 | local mouse = game.Players.LocalPlayer:GetMouse() |
02 | local throwshurikenAnim = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.ThrowShuriken) |
03 | script.Parent.Activated:Connect( function () |
04 | if not game.Workspace:FindFirstChild(script.Parent.Parent.Name.. "Shuriken" ) then |
05 | throwshurikenAnim:Play() |
06 | throwshurikenAnim.Stopped:Connect( function () |
07 | game.ReplicatedStorage.Message:FireServer( "ThrowShuriken" , script.Parent.Handle, mouse.Hit.p) |
08 | end ) |
09 | end |
10 | end ) |
ServerScript:
01 | game.ReplicatedStorage.ThrowShuriken.OnServerEvent:Connect( function (player, message, handle, mousepos) |
02 | local debounce = true |
03 | local shuriken = handle:Clone() |
04 | shuriken.Name = player.Name.. "Shuriken" |
05 | shuriken.Parent = workspace |
06 | shuriken.CanCollide = false |
07 | shuriken.Position = player.Character.RightHand.Position |
08 | handle.Transparency = 1 |
09 | local bodyVelocity = Instance.new( "BodyVelocity" , shuriken) |
10 | bodyVelocity.Velocity = (mousepos - shuriken.Position).unit* 50 *Vector 3. new( 1 , 0 , 1 ) |
11 | local bodyAngularVelocity = Instance.new( "BodyAngularVelocity" , shuriken) |
12 | bodyAngularVelocity.AngularVelocity = Vector 3. new( 0 , 120 , 0 ) |
13 | debris:AddItem(shuriken, 10 ) |
14 | shuriken.Touched:Connect( function (a) |
15 | print (a.Parent.Name.. ", " ..a.Name) |
When the handle clones the second time, 2 shurikens appear. When it clones the third time, 3 shurikens appear. But I only want 1 to appear each time. How can I fix this?
Okay, so this is simple. All you do is...
1 | local exampleModel = game.Workspace.exampleModel |
2 |
3 | while true do |
4 | wait( 60 ) -- Replace with however long you want a cooldown |
5 | exampleModel:Destroy() |
6 | wait( 0.001 ) |
7 | exampleModel:Clone() |
8 | end ) |
That was just an example of how you would clone a map or something like that. If you wanted to clone a model for a tool, you would do
01 | local toolModel = game.Workspace.toolModel |
02 |
03 | while true do |
04 | 'wait( 60 ) |
05 | toolModel:Destroy() |
06 | wait( 0.001 ) |
07 | toolModel:Clone() |
08 | wait( 0.001 ) |
09 | toolModel.Parent = game.Players.LocalPlayer.Backpack |
10 | end ) |
That would move the tool to the backpack of the local player.