I looked up how to and it didn't work.
target = game.Players.LocalPlayer:GetMouse().Hit function activated() local gunharm = Instance.new("Part", workspace) gunharm.Size = Vector3.new(2.61, 0.38, 0.37) gunharm.Touched:connect(function(hit) hit.Parent.Humanoid.Health = 0 end) gunharm.Material = Enum.Material.Neon gunharm.BrickColor = BrickColor.new("CGA brown") gunharm.Name = 'gunharm' game.Workspace.gunharm:MoveTo(Vector3.new(target)) wait(.8) gunharm:Destroy() end script.Parent.Activated:Connect(activated)
Just letting you know, this is a perfect opportunity to practice script analyzing through the output box and print debugging. Anyways, you have to set target while inside the function. Currently, mouse.Hit
is assigned to the place it was first called.
For a better explanation: Lets say target was assigned to {0,0,0} at run time, when you called the function, Target has not been reassigned so the target position is still at {0,0,0}