How do I fix this?

Im trying to make a ban script, but it doesn’t seem to be working. Im not sure why either.

Im not getting any error’s, but when I put in the print functions, it didn’t print kicked.

local character = script.Parent 
local player = game.Players:GetPlayerFromCharacter(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
local Rep = game:GetService("ReplicatedStorage")
local BanDetect = Rep:WaitForChild("Events"):WaitForChild("BanDetect")

humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
	local WalkSpeed = humanoid.WalkSpeed
	print("WalkSpeed")
	if WalkSpeed > 16 then
		print("fired")
		local success, errormessage = pcall(function()
			BanDetect:FireServer(player, "Speed")
			print("remote fired")
		end)
	end
end)

ServerScriptService Ban Script

local Rep = game:GetService("ReplicatedStorage")
local BanDetect = Rep:WaitForChild("Events"):WaitForChild("BanDetect")

local Data = game:GetService("DataStoreService")
local banDataStore = Data:GetDataStore("BanData")

BanDetect.OnServerEvent:Connect(function(player, banReason)
	if banReason == "Speed" then
		banDataStore:SetAsync(player.UserId, true)
		print("kicekd")

		player:Kick("Gameplay has reveiwed some suspicious movement, action has been taken.")
	elseif banReason == "JumpPower" then
		banDataStore:SetAsync(player.UserId, true)

		player:Kick("Gameplay has reveiwed some suspicious movement, action has been taken.")
	elseif banReason == "Health" then
		banDataStore:SetAsync(player.UserId, true)

		player:Kick("Gameplay has reveiwed some suspicious upgrades, action has been taken.")
	elseif banReason == "MaxHealth" then
		banDataStore:SetAsync(player.UserId, true)

		player:Kick("Gameplay has reveiwed some suspicious upgrades, action has been taken.")
	elseif banReason == "HipHeight" then
		banDataStore:SetAsync(player.UserId, true)

		player:Kick("Gameplay has reveiwed some suspicious upgrades, action has been taken.")
	end
end)

When you’re firing remote from client to server you don’t pass player argument when doing :FireServer().

So you should be doing :FireServer("Speed") without passing player

I hope this helps you with your issue :slight_smile:

2 Likes

obviously it doesn’t print kicked, but it would be a problem if it doesn’t print kicekd

I already pointed this out though…

I wouldn’t have made the post if it wouldn’t have been a problem?

i’m sorry it was a joke. (kicekd was not a typo on my end)

1 Like