Hello Developers, I’m making a hitbox and I wanted to make something like getting kicked when the size of the hitbox has been changed. But when I change the size manually its not kicking the player. Help please.
-- Get Needs
local Part = Instance.new('Part')
local Connector = Instance.new('Motor6D')
-- Needed Code
local Box = Part:Clone()
-- Config Box
Box.Name = 'Hitbox'
Box.Size = Character.Torso.Size
Box.Parent = Character
Box.CFrame = Character.Torso.CFrame
Box.CanCollide = false
-- Config Connector
Connector.Name = 'BoxConnector'
Connector.Parent = Character.Torso
Connector.Part0 = Character.Torso
Connector.Part1 = Box
-- Size Detect
if not Box.Size ~= Character.Torso.Size then
Player:Kick('Exploiting Detected. Changing hitbox size')
It’s probably not kicking you because changing the .Size property from the client will not replicate to the server. You probably need to find a different method for this, like checking from the client instead and telling the server that the player needs to be kicked.
It is working as intended. Roblox Client-Server Model. You will need to use a form of remote communication as well as a LocalScript if you want to detect changes on the client however, a smart exploiter could still be able to delete the remote as well as the LocalScript monitoring changes, that will lead us into the whole anti-exploit sector which is more of an advanced complex topic. Remote Functions and Events
Please go through the article and create some examples. I don’t have the energy to give you a step-by-step guide of what and what not to do but yes, an event firing to the server when a change is detected is more that enough.
Put this into a local script that’s inside StarterPlayerScripts:
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local function detectChanges(character)
local Box = Character:WaitForChild("Box", 5)
(Keep in mind this is not secure since it’s a local script)
I deal with a similar issue; how I fixed it was by sending a local script in that would check all the parts and make sure they equal the same size as their server side, if not; it would resize it so they can’t manipulate it. The local script then gets deleted from the server side to prevent any form of prevention and ways to stop the script from happening.
When a hitbox is expanded, it’s done so on the client side; so your server sided script can’t detect that… you need to use a RemoteEvent or a RemoteFunction and a local script to check the sizes and return that value to the server.