so i am trying to detect if someone that fired a remote event is not a certain rank they get banned.
but whenever i try this code I get this error
attempt to compare number < boolean
here is my code.
if not player:GetRankInGroup(9822548) > 1 then
local datastore = game:GetService("DataStoreService"):GetDataStore("Bans")
datastore:SetAsync(player.UserId, true)
wait()
player:Kick("Detected hacking.\nIf this is incorrect please message phyouthcenter1 on Discord.\nYou MUST be 13+ to use Discord.")
end
The problem could just be the arrangement of the arguments.
Fixed:
Added the extra brackets
if not (player:GetRankInGroup(9822548) > 1) then
local datastore = game:GetService("DataStoreService"):GetDataStore("Bans")
datastore:SetAsync(player.UserId, true)
wait()
player:Kick("Detected hacking.\nIf this is incorrect please message phyouthcenter1 on Discord.\nYou MUST be 13+ to use Discord.")
end
Works no more errors but it doesnt kick the player when i press the kick button can you help me fix this?
game.ReplicatedStorage.School.OnServerEvent:Connect(function(player, mode, target)
if not (player:GetRankInGroup(9822548) > 1) then
local datastore = game:GetService("DataStoreService"):GetDataStore("Bans")
datastore:SetAsync(player.UserId, true)
wait()
player:Kick("Detected hacking.\nIf this is incorrect please message phyouthcenter1 on Discord.\nYou MUST be 13+ to use Discord.")
end
if (player:GetRankInGroup(9822548) > 1) then
if mode == "warn" then
local warnStorage = game:GetService("DataStoreService"):GetDataStore("Warnings")
if game.Players:FindFirstChild(target) then
if game.Players:FindFirstChild(target).Warnings.Value == 2 then
warnStorage:SetAsync(target.UserId, 0)
target:Kick("Max warnings")
else
game.Players:FindFirstChild(target).Warnings.Value = game.Players:FindFirstChild(target).Warnings.Value + 1
wait(.1)
warnStorage:SetAsync(target.UserId, game.Players:FindFirstChild(target).Warnings.Value)
end
end
end
elseif mode == "kick" then
if game.Players:FindFirstChild(target) then
game.Players:FindFirstChild(target):Kick()
end
elseif mode == "ban" then
local datastore = game:GetService("DataStoreService"):GetDataStore("Bans")
datastore:SetAsync(target.UserId, true)
wait()
target:Kick("Banned.\nIf you feel like this ban is un-justified please message phyouthcenter1 on discord.\nYou MUST be 13+ to use Discord.")
end
end)
game.ReplicatedStorage.School.OnServerEvent:Connect(function(player, mode, target)
if not (player:GetRankInGroup(9822548) > 1) then
local datastore = game:GetService("DataStoreService"):GetDataStore("Bans")
datastore:SetAsync(player.UserId, true)
wait()
player:Kick("Detected hacking.\nIf this is incorrect please message phyouthcenter1 on Discord.\nYou MUST be 13+ to use Discord.")
end
if (player:GetRankInGroup(9822548) > 1) then
if mode == "warn" then
local warnStorage = game:GetService("DataStoreService"):GetDataStore("Warnings")
if game.Players:FindFirstChild(target) then
if game.Players:FindFirstChild(target).Warnings.Value == 2 then
warnStorage:SetAsync(target.UserId, 0)
target:Kick("Max warnings")
else
game.Players:FindFirstChild(target).Warnings.Value = game.Players:FindFirstChild(target).Warnings.Value + 1
wait(.1)
warnStorage:SetAsync(target.UserId, game.Players:FindFirstChild(target).Warnings.Value)
end
end
end
elseif mode == "kick" then
print('kick')
print(target)
if game.Players:FindFirstChild(target) then
print(target)
game.Players:FindFirstChild(target):Kick()
end
elseif mode == "ban" then
local datastore = game:GetService("DataStoreService"):GetDataStore("Bans")
datastore:SetAsync(target.UserId, true)
wait()
target:Kick("Banned.\nIf you feel like this ban is un-justified please message phyouthcenter1 on discord.\nYou MUST be 13+ to use Discord.")
end
end)
ok now it printing invalid target. it says the target is nothing.
game.ReplicatedStorage.School.OnServerEvent:Connect(function(player, mode, target)
print(target)
if game.Players:FindFirstChild(tostring(target)) then
if player:GetRankInGroup(9822548) > 1 then
if mode == "warn" then
local targetModel = game.Players:FindFirstChild(tostring(target))
local e = targetModel:WaitForChild("Warnings")
local warnStorage = game:GetService("DataStoreService"):GetDataStore("Warnings")
if e.Value == 2 or e.Value == 3 then
warnStorage:SetAsync(targetModel.UserId, 0)
targetModel:Kick("Max warnings.\nIf you will folow the rules, you may rejoin.")
else
local amt = e.Value + 1
warnStorage:SetAsync(targetModel.UserId, amt)
end
elseif mode == "kick" then
local targetModel = game.Players:FindFirstChild(tostring(target))
targetModel:Kick()
elseif mode == "ban" then
local targetModel = game.Players:FindFirstChild(tostring(target))
local banStore = game:GetService("DataStoreService"):GetDataStore("Bans")
banStore:SetAsyc(targetModel.UserId, true)
end
else
local datastore = game:GetService("DataStoreService"):GetDataStore("Bans")
datastore:SetAsync(player.UserId, true)
wait()
player:Kick("Detected hacking.\nIf this is incorrect please message phyouthcenter1 on Discord.\nYou MUST be 13+ to use Discord.")
end
else
print("Invalid target")
end
end)
How about putting the plr variable inside the functions instead? Since the variable is only checked on the start of the game meaning that even if the text changes, the variable will not change. So it will be like this: