I've been wondering if it was possible to inject a specific script from lighting, rep. storage, etc. into a model/tool with another script. (Not asking for a script, although it would be nice)
Just a yes or no question.
I've been wondering if it was possible to inject a specific script from lighting, rep. storage, etc. into a model/tool with another script. (Not asking for a script, although it would be nice)
Just a yes or no question.
Yes, it is. You can do this by using the Clone() method. For example follow these step's below;
- Make sure you know what script you want in the tool
- Make sure you place it in the ReplicatedStorage
- Make sure the script is Disabled
- Have another script (this will be clone script)
a simple example;
local script = game.ReplicatedStorage:WaitForChild('Script') -- we use waitforchild to wait for the child to be added.
game.Players.PlayerAdded:Connect(function(plr) -- fires when a player joins
local tool = plr.Backpack:WaitForChild('Toolname')
local CS = script:Clone() -- clones the script
CS.Parent = tool -- sends it to the tool
CS.Disabled = false -- change it to false so it will work
end)
Here's a few notes:
1.This script is made so that when the player join's the tool is already inside of the Backpack. So make sure the tool is already inside of the backpack. 2. For the first line, you might want to change "Script" to the name of your script that your going to clone 3. make sure you change the Toolname to the tool's name in player's backpack 4. this script will only work if the tool is in starter tools or something so it's in the player's backpack right away.
Good luck and have fun developing!
Yes, it is.
Use comments please, we don't need 3 word's as an answer.
"Just a yes or no question."
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
Awesome, thanks :D
No Problem!