My issue ended up being that with our vehicles in-game, the script would give off false-positives. Making it impossible for players to drive vehicles without their cars getting flung, etc.
So I applied some code to detect when a player is sitting, and when they are not. Then having the script check if they are sitting before running the anti-cheat code.
However, now it’s as if it just broke it completely. I can teleport anybody, and it will not teleport them to their previous origin as wanted previously.
wallet = script.Parent.Parent.Parent:FindFirstChild("tp",15)
local Plr = game.Players.LocalPlayer
local lastPos = Plr.Character.HumanoidRootPart.CFrame
local char = script.Parent
local hum = char:WaitForChild("Humanoid",15)
interval = 1
punishment = 1
local deb = false
hum.Sit:GetPropertyChangedSignal("Value"):Connect(function()
if hum.Sit.Value == true then
deb = true
else
deb = false
end
end)
while wait() do
if Plr:GetRankInGroup(4219097) < 100 and wallet.Value == false and deb == false then
currPos = script.Parent.HumanoidRootPart.Position
wait(interval)
nowPos = script.Parent.HumanoidRootPart.Position
distMoved = nowPos-currPos
maxMovable = interval*script.Parent.Humanoid.WalkSpeed
if distMoved.X > (maxMovable+10) or distMoved.X < -(maxMovable+10) or distMoved.Z > (maxMovable+10) or distMoved.Z < -(maxMovable+10) then
Plr.Character.HumanoidRootPart.CFrame = lastPos
end
end
end
lastpos is not defined. Also, you should use script.Parent.HumanoidRootPart.CFrame.Position.
wallet = script.Parent.Parent.Parent:FindFirstChild("tp",15)
local Plr = game.Players.LocalPlayer
local lastPos = Plr.Character.HumanoidRootPart.CFrame
local char = script.Parent
local hum = char:WaitForChild("Humanoid",15)
interval = 1
punishment = 1
local deb = false
hum.Sit:GetPropertyChangedSignal("Value"):Connect(function()
if hum.Sit.Value == true then
deb = true
else
deb = false
end
end)
while wait() do
if Plr:GetRankInGroup(4219097) < 100 and wallet.Value == false and deb == false then
currPos = script.Parent.HumanoidRootPart.Position
task.wait(interval)
nowPos = script.Parent.HumanoidRootPart.Position
distMoved = nowPos-currPos
maxMovable = interval*script.Parent.Humanoid.WalkSpeed
if distMoved.X > (maxMovable+10) or distMoved.X < -(maxMovable+10) or distMoved.Z > (maxMovable+10) or distMoved.Z < -(maxMovable+10) then
Plr.Character.HumanoidRootPart.CFrame = currpos
end
end
end
I get that and will work on that. However the script worked fine before I added the following line of code:
local deb = false
hum.Sit:GetPropertyChangedSignal("Value"):Connect(function()
if hum.Sit.Value == true then
deb = true
else
deb = false
end
end)
while wait() do
if Plr:GetRankInGroup(4219097) < 100 and wallet.Value == false and deb == false then
Oh, my bad. You need to use GetPropertyChangedSignal on the Humanoid itself.
wallet = script.Parent.Parent.Parent:FindFirstChild("tp",15)
local Plr = game.Players.LocalPlayer
local lastPos = Plr.Character.HumanoidRootPart.CFrame
local char = script.Parent
local hum = char:WaitForChild("Humanoid",15)
interval = 1
punishment = 1
local deb = false
hum:GetPropertyChangedSignal("Sit"):Connect(function()
if hum.Sit == true then
deb = true
else
deb = false
end
end)
while task.wait() do
if Plr:GetRankInGroup(4219097) < 100 and wallet.Value == false and deb == false then
currPos = script.Parent.HumanoidRootPart.CFrame.Position
task.wait(interval)
nowPos = script.Parent.HumanoidRootPart.CFrame.Position
distMoved = nowPos-currPos
maxMovable = interval*script.Parent.Humanoid.WalkSpeed
if distMoved.X > (maxMovable+10) or distMoved.X < -(maxMovable+10) or distMoved.Z > (maxMovable+10) or distMoved.Z < -(maxMovable+10) then
Plr.Character.HumanoidRootPart.CFrame = currpos
end
end
end
I tried implementing that exact code, and the script is still broken. Teleported a low rank to me, and they didn’t end up getting teleported back. Kind of strange.
Try adding some prints to see how far the script goes without stopping.
wallet = script.Parent.Parent.Parent:FindFirstChild("tp",15)
local Plr = game.Players.LocalPlayer
local lastPos = Plr.Character.HumanoidRootPart.CFrame
local char = script.Parent
local hum = char:WaitForChild("Humanoid",15)
interval = 1
punishment = 1
local deb = false
hum:GetPropertyChangedSignal("Sit"):Connect(function()
if hum.Sit == true then
deb = true
else
deb = false
end
end)
while task.wait() do
if Plr:GetRankInGroup(4219097) < 100 and wallet.Value == false and deb == false then
print("checking")
currPos = script.Parent.HumanoidRootPart.CFrame.Position
task.wait(interval)
nowPos = script.Parent.HumanoidRootPart.CFrame.Position
distMoved = nowPos-currPos
maxMovable = interval*script.Parent.Humanoid.WalkSpeed
print("checking 2")
if distMoved.X > (maxMovable+10) or distMoved.X < -(maxMovable+10) or distMoved.Z > (maxMovable+10) or distMoved.Z < -(maxMovable+10) then
print("teleporting")
Plr.Character.HumanoidRootPart.CFrame = currpos
end
end
end
This was difficult because I had to have somebody else take screenshots of their dev console while I teleported them. But after awhile, I think I got a better understanding of what’s going on.
It appears the script ran through everything right away. He believes he seen “set db true” and “set db false” as I added those prints. This all happened right when he joined the game however.
When I teleported him a second time to be certain, it appears there was not a single print in relation to the script.
Essentially, all prints except “Teleporting” appeared to run about when he joined the game. But when teleported 2nd time, nothing appeared.