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

how to Fire other script from script?

Asked by
Yuuwa0519 197
5 years ago
Edited 5 years ago

I have a tool where it clones itself. I want to run this script itself(not function inside or chunks, but script itself) but it seems i cant find a way to. When i searched for it, I found a method called dofile() but it won`t work.. Is there any way to do this? Also, is there a way not to make the script run when not needed, like it only runs when it is called. (The code below is what i kind of want to do) script1:

if --[[tool--]] .Parent ~= game.Workspace then  
    --call the script2
end

script2:

local toolClone = script.Parent:Clone()
toolClone.Name = "toolClone"
toolClone.Parent = game.Workspace--makes appear the tool to game, since it was in serverStorage

2 answers

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

ModuleScripts will not run automatically.

Aso, a bindable function might work for you.

`````` if [[--tool--]] ~= game.Workspace then

script.Parent:Fire()

end ``````

Script#2

game.Workspace.Event.Event:Connect(function() local toolClone = script.Parent:Clone() --Not sure why you'd want to clone the script, but okay. toolClone.Name = "toolClone" toolClone.Parent = game.Workspace end)

0
oh i planned to put destroy() the cloned script but totally forgot about it lol. Thankyou btw Yuuwa0519 197 — 5y
Ad
Log in to vote
0
Answered by
katclap 24
5 years ago
Edited 5 years ago

Probably the easiest way to do that, would to set the script to disabled and have the script controlling it to set it to

disabled = false

for instance in your case we would use:

if  [[--tool--]]  ~=  game.Workspace then
script.Parent.Disabled = false

end

0
thankyou:D it worked. Yuuwa0519 197 — 5y

Answer this question