local player = game.Players.LocalPlayer if not player.Character then print("waiting for character") player.CharacterAdded:wait(); char = player.Character else char = player.Character end local hum = char.Humanoid if hum.Sit == true then print("Player is sitting") hum.JumpPower = 0 end
This script is in a LocalScript, in StarterPlayerScripts.
The goal of my script is that if a player sits, that his jumppower will be set to 0.
Here is another simpler way, the seat has an awesome property called occupant
, which is whoever sat on the seat, if no one is currently sitting, it will be nil. So if we use this with a .Changed
event which checks if a property has changed. We can check if the occupant
property has changed, and if it has changed and the occupant is a player, we set his jumppower to 0!
And btw, your script is actually right, but the if statments are only checking once if the humanoid sitting, because if statments always check a condition once, so you have to put them inside of a loop or something so they contanly check. But this way is more efficient I think.
The paramater for the changed
event is whatever property was changed. And the occupant is actually the humanoid that is sitting.
local seat = script.parent seat.Changed:Connect(function(prop) if prop == "Occupant" then if seat.Cccupant:IsA("Humanoid") then local humanoid = seat.Occupant humanoid.JumpPower = 0 end end end)
And that should work!
Pretty simple line of code put a script inside a seat and then put this in.
script.Parent.Touched:Connect(function() wait(0.5) script.Parent.SeatWeld.Part1.Parent.Humanoid.JumpPower = 0 end)