Hi! I don’t understand what the error is and how to fix it, please help me
local player = game.Players.LocalPlayer
local jumpdisabled = false
player.Character.Humanoid.Seated:Connect(function(active,currentSeat)
if active then
if currentSeat.Name == "DriveSeat" then
player.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
jumpdisabled = true
print("выкл гуи прыжка")
local ContextActionService = game:GetService('ContextActionService')
game:GetService("ContextActionService"):BindActionAtPriority("LockSeat", function()
if jumpdisabled == true then
return Enum.ContextActionResult.Sink
end
end, false, Enum.ContextActionPriority.High.Value, Enum.PlayerActions.CharacterJump)
wait(2)
jumpdisabled = false
player.Character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
print("вкл гуи прыжка")
end
end
end)
This script in starterplayerscript
Error:
Players.lhacerl228.PlayerScripts.LocalScript:6: attempt to index nil with ‘Humanoid’ - Client
Now, problem here is when game opens a new server, it needs to be loaded so character to be loaded. You are requesting player’s character before game is set up to prevent getting this error you need to do.
First Solution
repeat task.wait() until game.IsLoaded()
The thing we are doing here is waiting until game is loaded so we can access since character is loaded add this before giving varibles to script which means this must be at first line.
SecondSolution
Now, you can also put script into startercharacterscripts which will allow you to access player’s character when character is created this will allow you to ability to get player’s character.
From these I prefer the first one since if you put into startercharacterscripts some people abuse creation of this script at character like exploiters or glitchers. So first one is the best.
Thanks a lot! I used the second method, since the first did not work, it still gave an error, only in a different place in the script. Can you tell me how you can protect yourself from exploits?
Well, for example the scripts you put inside startercharacterscripts goes into player’s character at there people can edit or delete or add local scripts to their character and server cannot see these changes like they can make them fly etc. Problem with startcharacterscripts those given every time when player’s character added again which if people know about this they will keep respawning theirself and lag the game to prevent this people put their scripts to starterplayerscripts since those given on join. If you asked for character releated exploits:
Flying
You should check for how much time they spent at air at x,y,z zone. (Zone for problem when people fall out of the world.
Walkspeed
You should check how much way they can go with “V” speed and “t” time. You cannot check it by accessing humanoid since exploiters change metatables of these values not their indexes.