Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Problems with LookVector when I set a part's velocity to it?

I'm making a script where if the player presses a key it would fire a shot from it's head. It does execute the script however it does not go in the player's direction and whenever I jump I get flung off.

(I know this script is causing the problem since I disabled this one for testing and I didn't get flung)

Here is my script:

elseif input.KeyCode == Enum.KeyCode.B and playerTeam == game.Teams.Zombies then
	local bloat = Instance.new("Part")
	bloat.Shape = ("Ball")

	bloat.Parent = character:WaitForChild("HumanoidRootPart")
	bloat.Velocity = character.HumanoidRootPart.CFrame.LookVector * 100 
	print(bloat.Position)  --prints (0, 0, 0) everytime
end

1 answer

✓ Accepted answer

u might have to insert a VectorForce + the bloat.Shape = Enum.PartType.Ball then u need to do in the vectorforce: create a new attachment, set it to attachment0 then do:

Attachment.Position = Ball.Position

attachment1 has to be the players humanoidrootpart so:

OtherAttach.Position = game.Players.LocalPlayer.Character.Head.Position

6 comments

0

What do you mean by "VectorForce + bloat.Shape = Enum.PartType.Ball" ?

0

the bloat.Shape should be Enum.PartType.Ball (sorry) :P

0

What would my script be after your changes I can't wrap my head around it.. I am currently looking at the wiki for what attachments are.

0

I just found out my spheres are appearing at 0, 0, -5 so I teleported my player there. It somewhat worked since it was firing the direction my rootpart was facing cause of the lookVector but it is not firing near my torso's position.

0

ill change it

0

Also if I’m making it do damage should I make a ‘cloning script’ and put it under the “sphere” or should I handle damage on the script that shoots it?

This discussion is preserved as it was. New answers, comments, and votes are closed.