1 | local char = game.Workspace:FindFirstChild( "Humanoid" ) |
2 |
3 | if char.walkspeed> 16 then |
4 | print ( "you hacker" ) |
5 | end |
Workspace.Script:1: attempt to index a nil value is the error.
My intentions are to make sure no one is speed hacking in my game, sense filteredenabled doesn't cover that. I want to eventually ban the player for the game in the if statement, but I used print to make sure it works, which it doesn't.
01 | game.Players.PlayerAdded:Connect( function (P) --When a player join this code run |
02 | P.CharacterAdded:Connect( function (C) -- This check if the character spawned |
03 | local Hum = C:FindFirstChild( "Humanoid" ) --This find the humanoid |
04 | Hum.Changed:Connect( function (Prop) -- This run when a property of the humanoid changes |
05 | if Hum.WalkSpeed> 16 then --If the walkspeed is superior to 16 |
06 | P:Kick( "you hacker" ) --Kick the player |
07 | end |
08 | end ) |
09 | end ) |
10 | end ) |
I hope this help :)
Do you wan't help and there is the script:
1 | local char = game.Players.LocalPlayer.Character.Humanoid |
2 | local player = game.Players.LocalPlayer |
3 |
4 | if char.WalkSpeed = = 16 then |
5 | player:Kick( "you hacker" ) |
6 | end |
1 | while true do |
2 | wait(. 01 ) |
3 | local player = game.Players.LocalPlayer |
4 | local char = player.Char or player.CharacterAdded:() |
5 | if char.Humanoid.WalkSpeed > 16 then |
6 | print ( "you're a hacker, be gone" ) |
7 | player:Kick( "Exploiting" ) |
8 | wait(. 01 ) |
Basicly u scripted it wrong.
01 | -- Local Script |
02 | -- Put inside StarterGui |
03 |
04 | local player = game:GetService( "Players" ).LocalPlayer |
05 | local char = player.Character |
06 | game.Players.PlayerAdded:Connect( function () |
07 | wait( 0.1 ) |
08 | if char:WaitForChild( "Humanoid" ).WalkSpeed = 16 then |
09 | print (Player.Name.. " is not a hacker." |
10 | else |
11 | print (Player.Name.. " is hacker." |
12 | end |
13 | end () |