This script should teleport a player to a position when E is inputed, i get the error in the title instead and it doesnt work, tough the error in the title is a warning and is in yellow
Code:
workspace.ChildAdded:Connect(function(Child)
if Child.Name == "YellowJeep" then
print("AddedJeep")
local TouchButton = false
local UIS = game:GetService('UserInputService')
local plr = game.Players.LocalPlayer
local Character = plr.Character
if not Character or not Character.Parent then
Character = plr.CharacterAdded:wait()
end
local Root = Character:WaitForChild('HumanoidRootPart')
wait(0.5)
local Part = workspace.YellowJeep:WaitForChild("VehicleSeat")
local Position1 = Part.Position
UIS.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
print("M")
TouchButton = false
local mag = (Part.Position - Root.Position).magnitude
if mag <= 20 then
Character:MoveTo(Position1)
else
print("PO")
end
end
end)
while wait(1) do
Position1 = Part.Position
end
end
end)
btw this is a LocalScript inside StarterPlayerScripts

3 comments
It means it doesn't exist, do
if not game.Workspace.YellowJeep then return endwhich line?
Instead us if not game.Workspace:FindFirstChild('YellowJeep') then return end right above line 13