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

how can I activate a script from a distance?

Asked by 5 years ago

I have a turret gun set up to fire at objects that come close to it, it has a long part that activates the gun when its touched, but this conflicts with other things. is there a way to activate a script when an object comes close to it?

--this is the code inside the long part used for activating from a distance--

script.Parent.Touched:Connect(function() script.Parent.Shoot.Disabled = false wait(1) script.Parent.Shoot.Disabled = true end)

--this is the script that gets turned on-- local cannon = script.Parent.Parent local barrel = cannon.Barrel local fireball = cannon.Fireball

local fireballcopy = fireball:Clone() fireballcopy.Parent = game.Workspace fireballcopy.Position = barrel.Position fireballcopy.Script2.Disabled = false fireballcopy.Script1.Disabled = false

is there a way to activate this script from a distance instead of a touched part?

0
There IS a way, but... you should create a Touched function inside a part, because that is the easy way. AIphanium 124 — 5y
0
magnitude numercookie13246 11 — 5y

Answer this question