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

Trying to check if walkspeed is 16 only and not over?

local char = game.Workspace:FindFirstChild("Humanoid")

if char.walkspeed>16 then
	print("you hacker")
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.

2 comments

0

You gotta find the player first. local char = game.Workspace:FindFirstChild("Humanoid") doesn't make much sense to me.

0

Run a loop that checks like every four second if the player has the speed above 16.

4 answers

game.Players.PlayerAdded:Connect(function(P) --When a player join this code run
	P.CharacterAdded:Connect(function(C) -- This check if the character spawned
		local Hum = C:FindFirstChild("Humanoid") --This find the humanoid
		Hum.Changed:Connect(function(Prop) -- This run when a property of the humanoid changes
			if Hum.WalkSpeed>16 then --If the walkspeed is superior to 16
				P:Kick("you hacker") --Kick the player 
			end
		end)
	end)
end)

I hope this help :)

1 comment

0

It will. OP just needs to test it :D

Do you wan't help and there is the script:

local char = game.Players.LocalPlayer.Character.Humanoid
local player = game.Players.LocalPlayer

if char.WalkSpeed == 16 then
player:Kick("you hacker")
end

2 comments

0

The default speed is 16. You will kick the player once they join XD

0

lol

while true do
wait(.01)
local player = game.Players.LocalPlayer
local char = player.Char or player.CharacterAdded:()
if char.Humanoid.WalkSpeed >16 then
print("you're a hacker, be gone")
player:Kick("Exploiting")
wait(.01)

Basicly u scripted it wrong.

-- Local Script
-- Put inside StarterGui

local player = game:GetService("Players").LocalPlayer
local char = player.Character
game.Players.PlayerAdded:Connect(function()
wait(0.1)
if char:WaitForChild("Humanoid").WalkSpeed = 16 then
print(Player.Name.. " is not a hacker."
else
print(Player.Name.. " is hacker."
end
end()

2 comments

0

.PlayerGui.LocalScript:7: 'then' expected near '=' (red line under 16)

0

Hah you did too.

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