Hello, could anyone help me debug this code?
Whenever I try to teleport back a stage in my obby game, the server side script says that I am “attempting to call a table value”. Both variables in line 6 and 7 print correctly, so I am unsure what is broken.
Thank you for looking at these scripts!
ServerScript for teleporting player:
local teleleportplayer = game.ReplicatedStorage.TeleportPlayer
local checkpoints = game.Workspace.Checkpoints
teleleportplayer.OnServerEvent:Connect(function(player, stagetoteleport)
print(tostring(stagetoteleport))
print(tostring(checkpoints:FindFirstChild(stagetoteleport).CFrame))
print(tostring(player.Character.HumanoidRootPart.CFrame))
player.Character.HumanoidRootPart.CFrame = checkpoints:FindFirstChild(stagetoteleport).CFrame + Vector3(0, 2, 0)
end)
LocalScript for handling button presses:
local player = game.Players.LocalPlayer
local gui = game.Players.LocalPlayer.PlayerGui.ScreenGui
local leftbutton = gui.LeftButton
local rightbutton = gui.RightButton
local stagelabel = gui.StageLabel
local stage = player.leaderstats.Stage
checkpoints = game.Workspace.Checkpoints
teleportplayer = game.ReplicatedStorage.TeleportPlayer
leftbutton.MouseButton1Click:Connect(function(player)
if stage.Value > 0 then
stagetoteleport = stage.Value - 1
teleportplayer:FireServer(stagetoteleport)
end
end)
Prints and errors: