i need help with solving this problem. i have changed the code many times and it still says the same error. basically, I am trying to get the player teleported to a certain part once they click on the GUI button but it is saying character is not found?
here is the script that is in the textbutton
local tppart = game.Workspace.Elevator.Teleports:WaitForChild("1")
script.Parent.MouseButton1Click:Connect(function(plr)
local plrname = plr.Character
local humanoidrootpart = plr.Character:FindFirstChild("HumanoidRootPart")
if humanoidrootpart then
humanoidrootpart.CFrame = CFrame.new(tppart.CFrame.p) + Vector3.new(0,0,0)
end
end)
local tppart = game.Workspace.Elevator.Teleports:WaitForChild("1")
script.Parent.MouseClick:Connect(function(plr)
local humanoidRootPart = plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")
if humanoidRootPart then
humanoidRootPart.CFrame = CFrame.new(tppart.CFrame.p) + Vector3.new(0,0,0)
end
end)
you’re not checking for the character and the hrp, try this maybe
edit: you also used mousebutton1click when it should be a clickdetector