I am trying to make a desk for my game. The staff working at the desk has a button that can teleport new players if they are sitting in the chair across from them. Sadly this doesn’t work for some players, and I can’t figure out why. I’ve tried replicating the error in Roblox Studios to no avail. When the error occurs the player is made to stand up yet doesn’t teleport to the desired location. Here is the code the button uses.
local debounce = false
local button = script.Parent
button.ClickDetector.MouseClick:Connect(function(player)
if debounce == false and player:GetRankInGroup(32519780) > 1 and script.Parent.Parent.Parent.RecruitSeat.Seat.Occupant ~= nil then
script.Parent.Color = Color3.new(0, 0, 0)
debounce = true
local hum = script.Parent.Parent.Parent.RecruitSeat.Seat.Occupant.Parent
if hum then
print("Teleporting")
hum.Humanoid.Sit = false
local Pos = game.Workspace.SecurityTeleport --Gets the Part to teleport to.
wait(.1)
hum:SetPrimaryPartCFrame(CFrame.new(game.Workspace["SecurityTeleport"].Position))
end
wait(5)
script.Parent.Color = Color3.new(0, 1, 0)
debounce = false
end
end)