Basically, I have a portal that only unlocks / works if you have at least 2 multiplier, however it throws the error “attempt to index nil with ‘WaitForChild’”. I have been trying for a while and I really can’t find out how to fix it, below is the script if you have an idea
local part = script.Parent
local telepart = script.Parent.Parent.Parent.Parent["Zone 1"].Teleport1
local playerService = game:GetService("Players")
part.Touched:Connect(function(hit)
local player = hit.Parent
local realplayer = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
if player then
if realplayer:WaitForChild("leaderstats").Multiplier.Value >= 2 then
player.HumanoidRootPart.Position = telepart.Position
end
end
end)
local part = script.Parent
local tp_part = script.Parent.Parent.Parent.Parent[“Zone 1”].Teleport
local plrs = game:GetService"Players"
part.Touched:connect(function(hit)
local char = hit:FindFirstAncestorOfClass"Model"
if char and plrs:GetPlayerFromCharacter(char) then
local plr=plrs:GetPlayerFromCharacter(char)
if plr.leaderstats.Multiplier.Value >= 2 then
char.HumanoidRootPart.CFrame = tp_part.CFrame
end
end
end)
Might be some spelling mistakes and incorrect syntax as I wrote it on phone. I’m assuming that your given code has the correct value name and indexes the correct teleport part.