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

How do you make a click F to sit and F to leave,disabling the space bar like in Vehicle Simulator?

Asked by 5 years ago

Hi there I just wanted to know if this is easily possible and if so how would I go about with making something like this.

This is a code from and old video of Dutch Developer which I have now fixed slighty. So how would I then go ahead to something as so?

local inputservice = game:GetService("UserInputService")

inputservice.InputBegan:connect(function(i,g)
    if i.UserInputType == Enum.UserInputType.Keyboard then
        if i.KeyCode == Enum.KeyCode.E then
            for _,Car in pairs(workspace.Vehicles:GetChildren()) do
                local Mag = (Car.DriveSeat.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
                if Mag <= Car.Configurations.Range.Value and Car.DriveSeat.Occupant == nil then
                    Car.Event:FireServer()
                    break
                end
            end
        end
    end
end)


while true do
    script.Parent.ImageLabel.Visible = false
    for _,Car in pairs(workspace.Vehicles:GetChildren()) do
        local Mag = (Car.DriveSeat.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
        if Mag <= Car.Configurations.Range.Value and Car.DriveSeat.Occupant == nil then
            local D3ToD2 = workspace.CurrentCamera:WorldToScreenPoint(Car.DriveSeat.Position)
            script.Parent.ImageLabel.Visible = true
            script.Parent.ImageLabel.Position = UDim2.new(0,D3ToD2.X,0,D3ToD2.Y,0)
            break
        end
    end
    wait()
end

1 answer

Log in to vote
0
Answered by 5 years ago

i think you have to make your own seat look at the roblow wiki it will explain how seats work so you can try to replicate it put than with a normal part and have keybind using the userInputService and if you want to make it mobile friendly use contextActionService

0
Yes, that's it. Alert_Initius 0 — 5y
Ad

Answer this question