I want to stop a moving object that uses a Tween with no BodyVelocity in it, via another script

Basically, I have this script that is a fireball. Most of the basics of the script are done, so I want to move onto a different script, that cancels out these moving objects, or future abilities that I might make, but seem to keep trying to no avail.

If I could get some assistance with this, I’d appreciate it so much.

You’d be better off adding a function/chunk of code into the existing script to handle this, first of all the references have already been declared so accessing them will be trivial & secondly it’s good practice to keep everything related to/regarding a particular thing/object/instance inside the same script.

You could use RemoteFunctions or BindableFunctions by calling them from the script you want to use to stop the tween and do the action on the scirpt that starts the tween or by using a ModuleScript

TweenService:Create() creates a TweenBase Instance, this means if you do:

local tween = TweenService:Create(Fireball,TweenInfo,goals)
tween.Parent = Fireball
tween.Name = "FireballVelocity"

From another script you could do:

Fireball:FindFirstChild("FireballVelocity"):Cancel() --or :Pause()
1 Like

When you say adding a function/chunk of code, you mean to the fireball to have a general script to use to cancel its movement/damage out, or a module script to do that?

Are there resources on BindableFunctions that I can look at to get an idea on how I can use that within the script? (Sorry, I’m still kind of new to the deving scene so I don’t have too much of a grasp on general things)

Sure there are, just take a look to the dev hub. Bindable events or functions are used to make two scripts of the same type communicate. BindableFunction | Roblox Creator Documentation

How would this work as I want the script to be more universal for magic projectiles.

Alright, I believe I have somewhat of an understanding on what BindableFunctions do, make a server event, only affect a server event, so now my question come in as how would I utilize this information and create a module out of it, so I can use it amongst various different moving objects similar to the fireball?

Alright they are 2 different methods

With BindableFunctions you should make the event when it is fired on a script and do something and on another script call it

With modules script you should make the tween outside of any function and then create two of them. 1 plays the tween, the other stops it

But it would be easier to use @Demonic_Anxiety 's method

I do enjoy trying out your methods much more, but the current issue I have is now

ServerScriptService.ActualFireball:64: attempt to index nil with 'OnInvoke'

with the BindableEvents

and the script is

	if Fireball.Cframe >= 30 and Playing then
		print("Fireball is moving!", Playing.PlaybackState)
		wait(1)
		Playing:Cancel()
		print("Fireball is stopping!")
	end
end

BindableEvents doesn’t fire the event .OnInvoke but the .Event event.