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

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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 ^^

0
Thank you so much for the help! HimoutoUmaruDomaChan 20 — 5y
0
np darkzerobits 92 — 5y
Ad

Answer this question