Value inside of Player cannot be Found

Hey, I am having trouble with a script. It is an antifly script for exploiters but since there is a jetpack I am trying to make it so if someone is flying when they have full fuel then they get kicked, but for some reason the script is saying that “Fuel” isn’t in the player when it very much is.

----------------------------------------------
-- Tuesday
-- Anti fly script by delinquent#0002 or HazeDelinquent on v3rmillion
-- June 29th, 2021
----------------------------------------------
-- Misc
local function Checker(Exploiter)
	if Exploiter.Character then
		local hrp = Exploiter.Character:WaitForChild("HumanoidRootPart")
		local epicray = Ray.new(hrp.Position, Vector3.new(0, -15, 0))
		local findraypart = game.Workspace:FindPartOnRay(epicray)
		if findraypart then
		else
			if Exploiter.Fuel.Value == "100" then
			Exploiter:Kick("ez") -- change this to your message
			end
		end
	end
end

-- Main
game:GetService("RunService").Heartbeat:Connect(function()
	for f, g in pairs(game:GetService("Players"):GetChildren()) do
		Checker(g)
	end
end
)

image
image

If you can help it would be appreciated!

You should Probably check if the Item actually Exists by doing:

local Fuel = Exploiter:FindFirstChild("Fuel") -- Instance or nil

if Fuel and Fuel.Value == "100" then -- if Fuel Exists and is equal to 100
    Exploiter:Kick("ez")
end

Also, How Early is the function running?

If you run the Function before the Value is Added, it can cause the Error as it couldn’t find the object yet

Yeah, I am no longer getting errors, but it doesn’t seem to kick you, no matter how fast you fly.

You can try changing this to just a number and not a string:

if Fuel and Fuel.Value == 100 then -- 100 is a number instead of a string

The same thing happens. I’m not sure whether its the script or the fuel…

local hrp = Exploiter.Character:WaitForChild("HumanoidRootPart")
local epicray = Ray.new(hrp.Position, Vector3.new(0, -15, 0))
local findraypart = game.Workspace:FindPartOnRay(epicray)

Here, when you cast the ray, it starts from the HumanoidRootPart. Because it starts inside the HumanoidRootPart, it hits the HumanoidRootPart, or the player’s leg.

So you can ignore the player’s model by doing this:

local hrp = Exploiter.Character:WaitForChild("HumanoidRootPart")
local epicray = Ray.new(hrp.Position, Vector3.new(0, -15, 0))
local findraypart = game.Workspace:FindPartOnRay(epicray, {hrp.Parent}) -- Now it should ignore the player.

I haven’t tested this, but I’ve looked at the FindPartOnRay API.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.