#Straight shot
56 messages · Page 1 of 1 (latest)
Use a tween
i tried but cant seem to do it right, im a novice. do you know how?
What didn't work?
it has a starting and end position but the bullets only go to the x axis
not by the gun
can i show the script?
"lua local tool = script.Parent
tool.Activated:Connect(function()
local bullet = Instance.new("Part")
bullet.Position = tool.Handle.Position
bullet.Size = Vector3.new(0.2, 0.2, 0.2)
bullet.Color = Color3.new(1, 0, 0)
bullet.CanCollide = true
bullet.Anchored = false
bullet.Parent = game.Workspace
local startPos = bullet.Position -- starting position of the part
local endPos = startPos + Vector3.new(10, 0, 0) -- ending position of the part
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, -1) -- creates a TweenInfo object with duration of 5 seconds and repeating infinitely
local tween = game:GetService("TweenService"):Create(bullet, tweenInfo, {Position = endPos}) -- creates a new tween with the part as the object to tween, the TweenInfo object we created earlier, and the ending position we defined earlier
tween:Play() -- starts the tween
wait(2)
bullet:Destroy()
end) /"
Not like that
you can use CFrame.Lookvector
or you make a Ray
i thank you for this but the problem is i have no idea how to write it
** You are now Level 1! **
I will tell you in one second
Does it work?
No, anything i try adding to the bullet related to moving does nothing
Since you have bullet travel time I recommend fastcast
He’s new so I imagine he doesn’t know what that is. If you wanna help I recommend linking what fast casting is
So your basically moving it only on the x axis
Since it’s bullet.Position + vector3.new(10,0,0)
yea pretty much
x,y,z
Bingo nice
So I do recommend look vector, do you understand how it works
Unless you want the bullet to go to the mouse
i only want it to go straight when clicked
Alright then lookvector
Do you want me to explain it or do you understand by reading up on it
please explain
Alright
So lookvextor basically goes however far forward from the part you want it to go. Let me explain
Lookvector * 5 will go 5 Studs
Forward
(One sec changing classes)
take your time i dont mind
Lookvector is a direction
That has been normalized/turned into 1’s
The vector3 dictates where the part is looking at
Eulers angle I think
So how I would do it is I would do bullet position += base.Lookvector * 250(or whatever range)
Now some issues you might run into.
1.) your bullet teleports
You need to tween/lerp it. I can also explain that as well
2.) your bullet goes a random direction.
You need to make sure the front of the part is facing the front of the gun.
Any other questions lmk
Some additional information,
Lookvector * -number = backwards
Rightvector * number = right
Rightvector * -number = left
Upvector * number = up
Upvector * -number = down
exactly how can i tween/lerp it?
actually i made it almost work with little to no change in the code. now the last thing is the end position of the tween for the bullet. it works flawlessly when its on the workspace but when on a tool it only picks the last spot where the end point on the workspace was and ignores the tool. do you know how do fix this?
ill send some documentation
id have to see it to tell you