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

How can i use lookvector to point my players head?

Asked by
Teeter11 281 Moderation Voter
9 years ago

Lets say i was making a gun.

( i am )

And i want to make im down sights.

Well, i can do this by using the players mouse.hit and aiming by this following line

weld1.C1 = CFrame.new(Player.Character.Head.CFrame.p,oldMouseHit):toObjectSpace(Player.Character.Torso.CFrame)

which is used in my mouse following head script

the gun parts are welded to the players head and the players head aimed to mouse.hit

but when i use these sequence of code

            Bullet = Instance.new("Part")
            Bullet.FormFactor = "Custom"
            Bullet.Name = "GunBullet"
            Bullet.Size = Vector3.new(.2,.2,.2)
            Bullet.CanCollide = false
            Bullet.CFrame = game.Players.LocalPlayer.Character.Head.CFrame
            Bullet.BrickColor = BrickColor.new("Really Black")
            Bullet.Velocity = game.Players.LocalPlayer.Character.Head.CFrame.lookVector * 500
            Bullet.Parent = game.Workspace

the head of the player wants to look at this part that is spawned in when the gun is shot and it causes some glitchy aiming

so i was wondering if there was any other way to do aim the players head to there mouse without making it glitch out

i also tried using mouse.origin

but i could not use that right

thanks for anyone who will help :D

0
You could use the targetfilter property of Mouse to keep the mouse from "interacting" with the Bullet. http://wiki.roblox.com/index.php?title=API:Class/Mouse/TargetFilter LightArceus 110 — 9y

1 answer

Log in to vote
-1
Answered by 9 years ago

http://wiki.roblox.com/index.php?title=API:Class/Mouse/TargetFilter

0
it doesnt work with mouse.hit Teeter11 281 — 9y
Ad

Answer this question