Hello everyone,I have problem with ontouch script. It should make supply chest disapear, but don't work ;s
Here is script:
local DebounceTime = 0.5 local Debounce = false local Sup = script.Parent.Parent:WaitForChild("Supply") local OnTouch = function(Part) if game.Players:GetPlayerFromCharacter(Part.Parent) and not Debounce then Debounce = true for _, child in pairs(Sup:GetChildren()) do if child:IsA("BasePart") or child:IsA("UnionOperation") then child.Transparency = 1 child.CanCollide = false end end wait(DebounceTime) Debounce = false end end script.Parent.Sup.Touched:connect(OnTouch)
I didn't saw any error output.
The problem might be when you're calling the function. Since basically the script is reading line 20 as this:
script.Parent.script.Parent.Parent:WaitForChild("Supply")
Which doesn't look right does it? Maybe you should try getting rid of the Script.Parent
bit in line 20, like this:
Sup.Touched:connect(OnTouch)
Hope this solved your problem! If you have anymore question then please feel free to post them down below!
EDITED:
local DebounceTime = 0.5 local Debounce = false local Sup = script.Parent.Parent:WaitForChild("Supply") local Model = script.Parent.Parent.Parent.SupplyChest local OnTouch = function(Part) if game.Players:GetPlayerFromCharacter(Part.Parent) and not Debounce then Debounce = true for _, child in pairs(Model:GetChildren()) do if child:IsA("Part") or child:IsA("UnionOperation") then child.Transparency = 1 child.CanCollide = false end end wait(DebounceTime) Debounce = false end end Sup.Touched:connect(OnTouch)
-UserOnly16Characters
If the code I gave you does not work then check the tree of the Touched event
Like does the script's parent have a child called "Sup" or?
local DebounceTime = 0.5 local Debounce = false local Sup = script.Parent.Parent:WaitForChild("Supply") script.Parent.Sup.Touched:connect(function(prt) if game.Players:FindFirstChild(prt.Parent.Name) and Debounce == false then Debounce = true for _, child in pairs(Sup:GetChildren()) do if child:IsA("BasePart") or child:IsA("UnionOperation") then child.Transparency = 1 child.CanCollide = false end end wait(DebounceTime) Debounce = false end end)