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

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

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

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

1 comment

0

Yes, that's it.

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