so i am making a bullet so it is going to call a function and in the function there is

raycast = game:GetService("RunService").Heartbeat:Connect(function()

so i am making it so the bullet will keep on traveling until it hits something or the movement code runs 300 times the making the raycast stop is this

raycast:Disconnect()

but what happens tho is that if i shoot 2 so two are in the air then when it disconnects it will disconnects the second bullet then if i shoot another bullet it will stop immediately because the count var is over 300 while the first bullets script is still running help would be greatly appreciated!

EDIT: so i had to put a

local raycast
raycast = game:GetService("RunService").Heartbeat:Connect(function()

so it sticks within the function also NEVER do this

local raycast = game:GetService("RunService").Heartbeat:Connect(function()

it will just give you an error

3 comments

0

I'm not completely sure about this, but I am fairly certain you can't set any event to a variable.

0

@SteamG0D You can

0

yeah it worked