Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Player can't sit again after sitting for the first time?

Basically trying to force a player to sit and exit on the push of F The player can sit perfectly fine the first time ( as well as get off ), but after getting off the first time the player can no longer get back onto the vehicleseat. simply put, why?

I havent been able to find any reasoning as to why the player is unable to sit again.

local UIS = game:GetService("UserInputService")
local PlayerInCar = game:GetService("ReplicatedStorage").Players:FindFirstChild(game.Players.LocalPlayer.Name).bv_InCar
local Car = game:GetService("ReplicatedStorage").Players:FindFirstChild(game.Players.LocalPlayer.Name).ov_Car

local function onInputBegan(input, gameProcessed)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		local key = input.KeyCode
		if key == Enum.KeyCode.F then
			print("PLAYER PRESSED F!")
			if game.Players.LocalPlayer:DistanceFromCharacter(PlayerInCar.Parent.vv_Position.Value) <= 10 then
				if PlayerInCar.Value == false then
					Car.Value.DriveSeat:Sit(game.Players.LocalPlayer.Character.Humanoid)
					print("PLayer should be seated!")
					PlayerInCar.Value = true
				elseif PlayerInCar.Value == true then
					PlayerInCar.Value = false
					local movevec2 = Vector3.new(Car.Value.Body.TeleportPart.Position.X, Car.Value.Body.TeleportPart.Position.Y, Car.Value.Body.TeleportPart.Position.Z)
					print("BRO ITS TRUE!")
					print("REMOVE FROM CAR")
					if game.Players.LocalPlayer.PlayerGui:FindFirstChild("A-Chassis Interface") then
						game.Players.LocalPlayer.PlayerGui:FindFirstChild("A-Chassis Interface"):Destroy()
					end
					game.Players.LocalPlayer.PlayerScripts.ls_DisableJumpRaw.Disabled = true
					game.Players.LocalPlayer.Character.Humanoid.Jump = true
					game.Players.LocalPlayer.Character:MoveTo(movevec2)
					script.Parent.frm_Main.Visible = true
				end
				
			end
		end
	end
end

UIS.InputBegan:connect(onInputBegan)

Any pointers or literally, anything, would be greatly appreciated. If you need context code let me know as well, i'll dig er out.

1 comment

0

I think it was the line 21 caused the problem... Not sure.

1 answer

Literally just added 0.01 wait time inbetween making the player jump and teleporting the player. yikes

This discussion is preserved as it was. New answers, comments, and votes are closed.