I'm trying to create a hopperbin that has multiple uses. I've gotten this tool to work when I press play while in the Studio, but if I run a server and use the tool in there, one part of it will break. This part involves taking part from inside the hopperbin itself, cloning it and placing it in the workspace.
I'm a bit new to coding, so I'm having a hard time figuring out what the problem is here. If anyone could help me with this, I would be very grateful.
local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Zanegsu-Slash-item?id=249793844" local Tool = script.Parent local Bullet = Tool:FindFirstChild("Part") --Player local plr = game.Players.LocalPlayer --UserInputService local uis = game:GetService('UserInputService') local shooting = true --Input Function function Input(i) --Check key if i.KeyCode == Enum.KeyCode.F then if shooting == true then shooting = false animTrack = plr.Character.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid animTrack:Play() --Clone Rocket local Rocket = Bullet:Clone() --Parent clone Rocket.Parent = workspace --Position clone Rocket.Position = plr.Character.IchigoTorso.Shot.Position --Rotation clone Rocket.Rotation = plr.Character.Torso.Rotation wait(5) shooting = true end end if i.KeyCode == Enum.KeyCode.E then animTrack = plr.Character.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid animTrack:Play() end end function onSelected() --Connect function uis.InputBegan:connect(Input) end script.Parent.Selected:connect(onSelected)
The line:
Rocket.Position = plr.Character.IchigoTorso.Shot.Position
Is referring to a model that I have attached to the player, which doesn't seem to be the problem with this script.
For anyone wanting to know the answer to this question, I moved the part that was inside the hopperbin into my lighting. I then changed line 4 to this:
local Bullet = game.Lighting:FindFirstChild("Part")
when you put
animation.AnimationId = "http://www.roblox.com/Zanegsu-Slash-item?id=249793844"
you dont put the whole link, just the ID.
Corrected Version:
01 local animation = Instance.new("Animation") 02 animation.AnimationId = "249793844" 03 local Tool = script.Parent 04 local Bullet = Tool:FindFirstChild("Part") 05 --Player 06 local plr = game.Players.LocalPlayer 07 --UserInputService 08 local uis = game:GetService('UserInputService') 09 local shooting = true 10
11 --Input Function 12 function Input(i) 13 --Check key 14 if i.KeyCode == Enum.KeyCode.F then 15 if shooting == true then 16 shooting = false 17 animTrack = plr.Character.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid 18 animTrack:Play() 19 --Clone Rocket 20 local Rocket = Bullet:Clone() 21 --Parent clone 22 Rocket.Parent = workspace 23 --Position clone 24 Rocket.Position = plr.Character.IchigoTorso.Shot.Position 25 --Rotation clone 26 Rocket.Rotation = plr.Character.Torso.Rotation 27 wait(5) 28 shooting = true 29 end 30 end 31 if i.KeyCode == Enum.KeyCode.E then 32 animTrack = plr.Character.Humanoid:LoadAnimation(animation) -- Load animation into Humanoid 33 animTrack:Play() 34 end 35 end 36
37 function onSelected() 38 --Connect function 39 uis.InputBegan:connect(Input) 40 end 41
42 script.Parent.Selected:connect(onSelected)