Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Where are the areas in this throwable item script that I could improve?

Asked by 4 years ago

I want to make it so that in my game there is an item that you can throw and pick up again. I found a tutorial that was fairly similar to my idea. So I edited the code a little but it doesn't really work.

local Tool = script.Parent
local vel = Instance.new("BodyVelocity")

Tool.Equipped:Connect(function()
    Tool.Activated:Connect(function()
     Tool.Parent = workspace
      game.ReplicatedStorage.RemoteEvent:FireServer("3552150170")
      wait(5)
      vel.Parent = Tool
      vel.Velocity = game.Players.LocalPlayer.Character.Head.CFrame.lookVector * 90
  wait(0.2) 
  Tool.Enabled = true
  Tool:Destroy()
  end)
end)
 wait(5)
script.Parent:Destroy()
Touch = script.Parent.Touched:Connect(function(g)
 if g.Parent:FindFirstChild('Humanoid') or g.Parent:FindFirstChild('Baseplate') then
  script.Parent.Anchored = true
  script.Parent.CanCollide = false
  wait(2)
  script.Parent:Destroy()
 end
end)

All the tool does is when you left click with it, your avatar kinda swishes it around? Plus, it ignores the animation I put into the script. A little bit of help would be appreciated!

Answer this question