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
)
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
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.