how can i make a button that toggles the ability to get out a seat when its pressed
2 Likes
In a local script you can use MousButton1Down to detect when the player clicks the button and set Humanoid.Jump property to true. You can also check if the player is sitting or not and hide/show the button accordingly by listening to the Humanoid.Seated event. Here’s some sample code.
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Humanoid = Player.Character:WaitForChild("Humanoid")
local Button = script.Parent -- or wherever the button is located
Button.MouseButton1Down:Connect(function()
if Player.Character and Player.Character:FindFirstChild("Humanoid") then
Player.Character.Humanoid.Jump = true
end
end)
function onSeated(isSeated, seat)
if isSeated then
Button.Visible = true
else
Button.Visible = false
end
end
Humanoid.Seated:Connect(onSeated)
2 Likes
how can i make it for like a plane so when the pilot presses it only the people on the plane cant jump?
1 Like
Inside the MouseButton1Down function you can fire an event to the server and in a server script you would set the JumpPower of all players except the pilot to 0.
-- in a local script
Button.MouseButton1Down:Connect(function()
RemoteEvent:FireServer()
end)
-- in a server script
RemoteEvent.OnServerEvent:Connect(pilot)
for _, player in pairs(game.Players:GetPlayers()) do
if player ~= pilot then
player.Character.Humanoid.JumpPower = 0
end
end
end)
1 Like
for some reson it didnt work do you know why
1 Like
i need it so all the people on the plane and the pilot and co pilot cant jump when i press the button