Why does my script not make my player jump and not show my gui?

Hi there! I am trying to make a script that makes a player who is not on the correct team (this being the manager team) jump and be teleported, all while making a clone of a gui in PlayerGui. I simply get no errors and no response from the script. What have I done wrong?

-- This LocalScript detects whether a player is in the correct team, Hotel Manager. If they are not a hotel manager, they will be kicked out of the manager seat and an alert gui will be shown.
local LocalPlayer = game:GetService("Players").LocalPlayer
local Team = game:GetService("Teams")
workspace.mgrSeat.Seat.ChildAdded:Connect(function(char)
	if char.Name == "Weld" and char:IsA("Weld") then
		local character = char.Part1.Parent
		if LocalPlayer.Team == Team.HotelManager then
		return end
	elseif LocalPlayer.Team == not Team.HotelManager then
		LocalPlayer.Character:FindFirstChild("Humanoid").Jump = true
		LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(77.743, -294.9, -96.644)
		local warning = LocalPlayer.PlayerGui.gameResponse.WarnCharacter:Clone()
		warning.Visible = true
		warning.Title = "Oops! You must be a manager to sit in that chair."
		warning.ContinueButton.MouseButton1Down:Connect(function()
			warning:Destroy()
		end)
		end
	end)

I’m pretty sure Char.Name == ‘Weld’ should actually be Char.Name == ‘SeatWeld’

Edit: I’m a little confused how some if this works, you seem to be checking the seats child added to see if a character is actually in there, but then only actually do anything if it’s not a weld.

First often I’d recommend using Seat:GetPropertyChagedSignal(‘Occupant’) to detect when people get in your seat, and then just Seat.Occupant to get the character.

Second to remove the player from the Seat, you should destroy the weld between the character and the Seat and then teleport them, instead of jumping them.

That seems to be fixing one issue, but my second issue still stands, I don’t jump/teleport/warn player

Is it possible that LocalPlayer.Team == Team.HotelManager isn’t the correct way to determine whether a player is in a team?

local LocalPlayer = game.Players.LocalPlayer
local Team = game:GetService("Teams")
workspace.mgrSeat.Seat.ChildAdded:Connect(function(char)
	if char.Name == "Weld" and char:IsA("Weld") then
		local character = char.Part1.Parent
		if LocalPlayer.Team == Team.HotelManager then
		return end
	
	else
	
		LocalPlayer.Character.Humanoid.Sit = false
		LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(77.743, -294.9, -96.644)
		local warning = LocalPlayer.PlayerGui.gameResponse.WarnCharacter:Clone()
		warning.Visible = true
		warning.Title = "Oops! You must be a manager to sit in that chair."
		warning.ContinueButton.MouseButton1Down:Connect(function()
			warning:Destroy()
		end)
		end
	end)

Try this
I was able to make the player jump up using Humanoid.Sit = false

Can’t say I know why the gui doesn’t work, but to force the player to jump do

LocalPlayer.Character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)

Also for teleporting the player, I would recommend teleporting them to a part instead of a fixed coordinate so you can easily change the teleport location. Make an invisible and noncancollide brick where you want the player to be teleported and do

LocalPlayer.Character.HumanoidRootPart.CFrame = CFrame.new(game.Workspace.TeleportTo.Position)

Ok, I modified my script. I am following all of your suggestions, including teleporting the player to a brick, but I still have no movement. Is this script supposed to be a LocalScript or ServerScript?

     local seat = workspace.mgrSeat.Seat
    local character = seat.Occupant
    local player = game:GetService("Players"):GetPlayerFromCharacter(character)

    local TeamService = game:GetService("Teams")

    seat:GetPropertyChangedSignal('Occupant'):Connect(function()
    	if player.Team == TeamService.HotelManager then
    		return
    	elseif player.Team ~= TeamService.HotelManager then
    		seat:FindFirstChild("SeatWeld"):Destroy()
    		character:FindFirstChild("HumanoidRootPart").CFrame = CFrame.new(workspace.blockTP.Position)
    	local warningGui = player.PlayerGui.gameResponse.WarnCharacter:Clone()
    		warningGui.Visible = true
    		warningGui.Title.Text = "Oops! You must be a manager to sit in that chair."
    		warningGui.ContinueButton.MouseButton1Down:Connect(function()
    			warningGui:Destroy()
    		end)
    	end
    end)

Here’s my version of the script:

local Players = game:GetService("Players")
local TeamService = game:GetService("Teams")

local Seat = script.Parent
local Pos = Vector3.new(0, 10, 0) -- Change the position

local function CheckTeam(Plr)
	if Plr.Neutral or not Plr.Team then
		return false
	end
	return Plr.Team
end

Seat:GetPropertyChangedSignal('Occupant'):Connect(function()
	if not Seat.Occupant then return end
	local Hum = Seat.Occupant
	local HRP = Hum.Parent:FindFirstChild("HumanoidRootPart")
	local Plr = Players:GetPlayerFromCharacter(Hum.Parent)
	if not Plr or not HRP then return end
	if CheckTeam(Plr) ~= TeamService.HotelManager then
		wait()
		Seat:FindFirstChildOfClass("Weld"):Destroy()
		wait()
		HRP.CFrame = CFrame.new(Pos)
		local M = Instance.new("Message")
		M.Text = "Oops! You must be a manager to sit in that chair."
		M.Parent = Plr.PlayerGui
		game.Debris:AddItem(M, 4)
	elseif CheckTeam(Plr) == TeamService.HotelManager then
		-- Do manager stuff.
	end
end)

It must be a Server Script and parented inside the seat, like this:

image

local Players = game:GetService("Players")
local TeamService = game:GetService("Teams")

local Seat = workspace.mgrSeat.Seat
local Pos = Vector3.new(workspace.blockTP.Position) -- Change the position

local function CheckTeam(Plr)
	return Plr.Team
end

Seat:GetPropertyChangedSignal('Occupant'):Connect(function()
	if not Seat.Occupant then return end
	local Hum = Seat.Occupant
	local HRP = Hum.Parent:FindFirstChild("HumanoidRootPart")
	local Plr = Players:GetPlayerFromCharacter(Hum.Parent)
	if not Plr or not HRP then return end
	if CheckTeam(Plr) ~= TeamService.HotelManager then
		print("You are not a hotel manager")
		Hum:ChangeState(Enum.HumanoidStateType.Jumping)
		HRP.CFrame = CFrame.new(Pos)
		local M = Plr.PlayerGui.gameResponse.WarnCharacter:Clone()
		M.Title.Text = "Oops! You must be a manager to sit in that chair."
		M.Parent = Plr.PlayerGui.gameResponse
		M.Name = "WarnCharacterManager"
		M.ContinueButton.MouseButton1Down:Connect(function()
			M:Destroy()
		end)
	elseif CheckTeam(Plr) == TeamService.HotelManager then
		print("you are a manager")
		return
	end
end)

I used your script but still had an issue with the player jumping up. I get the error/warning “Something unexpectedly tried to set the parent of SeatWeld to NULL while trying to set the parent of SeatWeld. Current parent is Seat.” In the script, I tried to make the player jump instead of just deleting the SeatWeld but I still had no effect. The player is detected as not being in the manager team/being in it, just no jumping occurs.

Did you add an delay before deleting the weld?

This is important for it to work properly.

I completely forgot about that, thank you for reminding me about that! My gui still doesn’t show, which is a bit of an issue for me. – edit, nevermind just forgot to make the gui visible! Thank you all once again