Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

how can I activate a script from a distance?

Asked by 11 months 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 — 11mo
0
magnitude numercookie13246 11 — 11mo

Answer this question