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

Is not a valid member of model ?

So i created a script but when i lauch it its doesnt work the error is : Pad is not a valid member of model ..

My Script is a localscript inside athe PayerGui and the objetive is too be tp when i click on a button of a surfacegui

Click on View Source to see all the script !

local player = game.Players.LocalPlayer


workspace:WaitForChild("Elevator"):WaitForChild("Elevator2"):WaitForChild("Box1").Pad.SurfaceGui.Main.Labo.MouseButton1Click:Connect(function()
	
	if player.Character and player.Character:FindFirstChild("Torso") then
		player.Character.Torso.CFrame = CFrame.new(-255.568, 7112.789, -4616.95)
	end
end)

So if you know to fix that this will e great!

PS:I already tested with only waitforchild is doesn't work

2 comments

0

Try using :FindFirstChild("Pad"), as the game thinks you are looking for a property of Model called "pad" (you might need to capitalize it, as you seem to have some shift-hitting issues...)

0

try making seperate variables, that line is really long

1 answer

You should separate all your variables to prevent confusion. Wait and see which one errors in your output and you'll know which one is your problem. In your case, it's saying Pad isn't inside of Box1, indicating your Parents are wrong.

local player = game.Players.LocalPlayer
local Elevator = workspace:WaitForChild("Elevator")
local Box1 = Elevator:WaitForChild("Box1")
local Pad = Box1:WaitForChild("Pad")
local SurfaceGui = Pad:WaitForChild("SurfaceGui")
local Main = SurfaceGui:WaitForChild("Main")
local Labo = Main:WaitForChild("Labo")

local character = player.Character or player.CharacterAdded:wait()
local torso = character:WaitForChild("HumanoidRootPart")
local cf = CFrame.new(-255.568, 7112.789, -4616.95)

Labo.MouseButton1Down:Connect(function()
	character:SetPrimaryPartCFrame(cf)
end)

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