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

How would I go about combining multiple scripts into a sigular one?

Asked by 5 years ago
Edited 5 years ago

Hi, I have this very basic "face changer" script that you place inside of a block with a decal on it, and when you touch the decal, your face copies the decal onto it. Now I have several of these decal blocks lined up with a script in each one and wanted to create a overarching script that could substitute each script for a single one. How would I go about doing this? I would want the player to touch one of the decals and for that decal to appear on their face. There would be serval decal blocks all next to each other.

Thank you in advance! Any feedback is great!

This is the script/code for one block. I was thinking of maybe giving each block a numbervalue?

01// My workspace looks like this:
02//Model
03//-FaceChanger
04//  -Decal
05//-FaceChanger
06//  -Decal
07 
08 
09//Maybe I do like
10 
11//Model
12//-FaceChanger1
13//  -Decal
14//-FaceChanger2
15//  -Decal
View all 44 lines...

2 answers

Log in to vote
0
Answered by
0msh 333 Moderation Voter
5 years ago

you can have a script inside of ServerScriptService and do something like this:

never tested it, may have some errors

01local decals = game.Workspace:GetDescendants()
02for i,v in pairs (decals) do
03if v:IsA("Decal") then -- check if the descendant is a decal
04    if v.Parent.Name == "FaceChanger" then -- the decal's parent's name
05        v.Touched:Connect(function(hit)
06            -- clones the texture to the hit.Parent's face, make sure to check if their humanoid is present first
07        end)
08    end
09end
10end
0
Thank you, and I love the idea of putting it in the ServerScriptService although it didn't work. I appreciate it tho! 2sail2you 4 — 5y
0
why didnt it work? royaltoe 5144 — 5y
0
Take a look at what I wrote in the comments below, but basically nothing happens if I touch the part with a decal in it. Not sure what I should do 2sail2you 4 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

This is what I now have in the serverscriptservice

01function getDecal()
02local decals = game.Workspace:GetDescendants()
03 
04for i,v in pairs (decals) do
05if v:IsA("Decal") then -- check if the descendant is a decal
06    if v.Parent.Name == "FaceChanger" then -- the decal's parent's name
07        v.Touched:Connect(function(hit)
08            -- clones the texture to the hit.Parent's face, make sure to check if their humanoid is present first
09        end)
10    end
11end
12end
13end
14 
15function onTouch(hit)
View all 27 lines...
0
And that works? moo1210 587 — 5y
0
No unfortunately not :/ 2sail2you 4 — 5y
0
dude, you need to put the on touch function below v.Touched, you connected the function to script.Parent which would be ServerScriptService 0msh 333 — 5y
0
It is below? 2sail2you 4 — 5y
0
no it's not... you're not connecting the right functions, i suggest you go watch some tutorials on the basics first 0msh 333 — 5y

Answer this question