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: |
17 | //If I did that, I would need to change function getDecal() but this is where I get lost |
20 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
21 | local head = hit.Parent:FindFirstChild( "Head" ) |
23 | local face = head:FindFirstChild( "face" ) |
24 | if face.Texture ~ = getDecal().Texture then |
25 | face.Texture = getDecal().Texture |
34 | for i,child in pairs (script.Parent:GetChildren()) do |
35 | if child.className = = "Decal" then |
36 | table.insert(decals, child) |
40 | return decals [ math.random( 1 , #decals) ] |
44 | script.Parent.Touched:Connect(onTouch) |