You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I’m currently trying to make a bullet trail, that tweens away after (I think) .2 seconds. Seems simple, and that’s what I thought until I ran into this:
It may be hard to see, but the tween is inconsistent, and happens on some clicks and not on others. In this example I was spam clicking to “simulate” a machine gun if I were to make this into one (for testing purposes).
I’ve tried quite a few things to fix this. I’ve lowered the time it takes to tween, I’ve moved the tween out of a function (thinking maybe that slows it down/breaks it) but I’m not sure what else to do, rather than ask for help here.
Here’s the important code!
if raycastResult then
print("Hit something")
local hitpart = raycastResult.Instance
print(hitpart.Name)
local distance = (rayOrigin - raycastResult.Position).Magnitude
p.Anchored = true
p.CanCollide = false
p.Transparency = .3
p.Parent = game.Workspace
p.Size = Vector3.new(0.1, 0.1, distance)
p.CFrame = CFrame.lookAt(rayOrigin, raycastResult.Position)*CFrame.new(0, 0, -distance/2)
Tween:Play()
print("Finished")
--CreateVisibleRay(true, rayOrigin, raycastResult, rayDirection, rayOrigin)
if hitpart.Parent:FindFirstChild("Humanoid") then
print("Found one!")
else
print("No humanoid")
end
else
--CreateVisibleRay(false, rayOrigin, raycastResult, rayDirection, rayOrigin)
local distance = (rayOrigin - rayDirection).Magnitude
p.Anchored = true
p.CanCollide = false
p.Transparency = .3
p.Parent = game.Workspace
p.Size = Vector3.new(0.1, 0.1, distance)
p.CFrame = CFrame.lookAt(rayOrigin, rayDirection)*CFrame.new(0, 0, -distance/2)
Tween:Play()
print("Finished")
end
for some context, I’m using a tool for activation, then a remote event to tell the server to do all of the stuff above (plus some unneeded code for this question).
Thanks in advanced if you can help!