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

Script does not work with multiple parts and idk what to do, can someone help me debug this?

I tried to use some ways that I thought were correct, but none of them worked correctly.

This is the original script:

local Workspace = game:GetService("Workspace")

-- Part Locations

local ClickPart = Workspace:FindFirstChild("ClickPart") --Touching Part
local ChangingPart = Workspace:FindFirstChild("ChangingPart") --Changing Part

-- Processing Section
   
   local function changingPartsProperties (Hit) --Creating function [The `Hit` is a parameter which tells us `What touched the part?`
	local Character = Hit.Parent
	local Humanoid = Character:FindFirstChild("Humanoid") --Checking if what hit the part has a humanoid

    if Humanoid then --If humanoid is found then....
	    print("Changing Properties")
	    ChangingPart.Transparency = 0.5
	    ChangingPart.CanCollide = true
	end
end

--Connecting Section

ClickPart.Touched:Connect(changingPartsProperties) --Connecting `Touched` event

And I tried: local ChangingPart = Workspace:FindFirstChild("ChangingPart","ChangingPart2") --Changing Part

And: local ChangingPart = Workspace:FindFirstChild("ChangingPart") --Changing Part Workspace:FindFirstChild("ChangingPart2") --Changing Part 2

But they don't work. I hope someone can help me because I tried my best to debug it.

(Also, the original script does not work if the ChangingPart if it's inside a model. I have no idea how to fix this either and it would be appreciated if I got help but it's not my main concern.)

1 answer

✓ Accepted answer

try this :

local ChangingPart2 = game.Workspace:FindFirstChild("ChangingPart2")

put this together with the other "locals" and if you want increase the ammount, then duplicate this script and change the number, oh, and these parts :

ChangingPart2.Transparency = 0.5
ChangingPart2.CanCollide =  true

`with the function that activates when the humanoid is finded ^^

2 comments

0

Thank you so much for the help!

0

np

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