Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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.

0
I think it was the line 21 caused the problem... Not sure. Xapelize 2658 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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

Ad

Answer this question