Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to Fire other script from script?

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

✓ Accepted answer

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)

1 comment

0

oh i planned to put destroy() the cloned script but totally forgot about it lol. Thankyou btw

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

1 comment

0

thankyou:D it worked.

This discussion is preserved as it was. New answers, comments, and votes are closed.