#Hitboxes
1 messages · Page 1 of 1 (latest)
For swords I would use touch events
For punches I would use GetPartBoundsInRadius
For ranged weapons I would use touch but if you don't like physics based projectiles you can use raycast or shapecast
For explosives I would use GetPartBoundsInRadius
All hitbox detection relays on the clients position data so there all exploitable
You would need a antihack to keep track of the players characters position
Uh, so there is a different ansver for every single weapon?
i just used Hitbox method in redplys combat videos
how does GetPartBoundsInRadius work?
I see that it uses Vector3, how would you get the radius infront of a player's cframe
I typically use for example part.CFrame = char.CFrame + CFrame.new(0,0,-1)
What I would do is connect a event to the punch keyframe and then use the hands position
Or you can do the same thing that you do with cframes
ah i was thinking it like how i made my hitbox for combat
should you do this on the server? my hitboxes for combat is currently in the server but might try the method you shared there instead of using a hitbox
Cant you punch in combat?
wym?
What do you mean by combat
oh like just punching so far
i got animation events and then when the animation event is fired it will create a hitbox on the server
OK I'm talking about the same thing
I would have a punch animation
And on the keyframe when the hand is extended out
Do a radius check around the hand
If it touching a object that can be hit
Send a remote event to the server
Server will do the sanity checks
Then deduct the health from the other object
ok
if i was doing a sword
i would have a part welded to the sword
can be invisable
when i start playing the animation
i would connect a touch event
when the animation ends i would remove the touch event
if the touch event detects anything that it can hit a remote event is sent to server
and server does sanity checks
Right now what my combat module does is: check if the player is in cd before letting them punch, then sends a remote to the server saying who's punching, it then plays the animation on the server and then when the animation event is fired it will create the hitbox on the server where it then checks who is touching it and then does damage and then fires the knockback remote event
and deducts the health
just a debounce, but i also got a stun table that prevents people from punching if they have been stunned
well, the debounce is local, the checks if they are in the stuntable is done on the server before the server then plays the animation
which then creates the hitbox etc
did you know that the client can also play the animation and it will replicate to the server?
use raycats hitboxes for swords/melee weapons and use OBB overlap detection (or if you dont want to implement your own OBB system use getpartboundsinbox) if you want more of a hand-to-hand combat type hitbox.
yeah but i wasnt sure about the combat table
like can localscripts get access to module scripts?
not the servers modulescript but there own modulescript yes
ok
hm not sure how i can get a copy of the stun table on the client
i mean in a local script
for the validity
stun table? combat table? are you using sushimaster's combat system tutorial?
no redplys
does he make a module script that stores that type of data?
ye
rather than doing that, i think it is better to make other modules that do so. such as a cooldown module where you can do cooldown.new(player, move: string, duration: number)
and another function that is along the lines of cooldown.active(player, move: string): boolean
the cd is just a debounce
the way i would do it is
client checks the cooldown and also makes sure there not stunned then client plays the animation then client detects the hit and then sends the server a remote event if there is a hit then the server will check a server sided cooldown and also the clients position using the antihack and also if the player is stuned if all checks pass the server will deduct the health
how would i make the client aware if they are stunned or not
checking cd on client does not really seem useful
perhaps it does eliminate some event calls but
any way is fine attributes is a option
in the end the check on the client seems useless
yes, as suphi mentioned, attributes are a really good way to handle this dilema
this is how redplys did the stuntable
its not useless you dont want to send events if you know the server wont exept them sending events is not free
also you dont want to play the punch animation on the clientside so you need a cooldown
yes, suphi is correct, and he has provided a great alternative
using attributes
they are replicated across cluent and server and so you can do client and server checks
however, i dont think attributes can hold table values
there is also a specil way
depending on how your stun works
its posible for the client to know it got stun with seeds and perlin noise
my stun just slows the player down
and makes them not do combat
or with random.new(seed)
oh ok
Discord: https://discord.gg/bEn49K5JUt
Patreon: https://www.patreon.com/Suphi
Donate: https://www.roblox.com/games/7532473490
Random: https://create.roblox.com/docs/reference/engine/datatypes/Random
DevForum: https://devforum.roblox.com/t/a-random-feature/64517
PCG: https://www.pcg-random.org/
Wikipedia: https://en.wikipedia.org/wiki/Permuted_c...
suphi, is running a remote function more performant than performing a remote event call
the condition that plays it on the server checks if they been stunned ``` if not dictionary_handler.find(Character,"Stunned") then
this video might teach you how to use seeds for the client to know if it got stun without using any network data
okay i'm going to save this conversation and try work on a smoother combat system
remote functions are essentially 2 remote events so a remove function is like a remote event being sent to the server then the server responding back to the client with another remote event
thanks a lot @smoky sandal and @frozen bay
your welcome
Okay so uhhhh
Is there any way for a single hitbox to handle all of the weapons I specified
If I was forced to just use 1 method I would pick touch
You would have to make a invisible part for explosions
But it would be easyer to use get parts bounds in radius
But that would be like tying one hand behind your back
*tying
but can i weld the position it needs to check to the character. so like if the player moves, the hibox will also move?
why is the hitbox a separate part? you can if you want to
i personally like to detect hits to the actual parts of the enemy
but if you want to make hitting easier by increasing the size of the hitbox you can add a invisible part on the enemy or you can add a invisible part on the sword etc..
Doesnt using .touch suck
no it doesnt suck
touched uses physics which runs at 240hz while the script runs at 60hz, this means if moved too fast in and out of the frame the touched event might detect it even though its not inside of it or did not move in the client.
spatial query & ray casting runs at 60hz whilst the physics runs at 240hz so this means if the projectile is fast enough these two might not detect it
also touched is basically free in terms of perfomance
@upper sorrel there are other threads talking about this you should take a look at them and read through
a problem with touched is that u can fire the event for other players so basically what that means is if ur a hacker in an obby game u can get a kill brick and move into other players and kill them
Just check what the position is relative to the player and where the hitbox should be, and if its more than its suppost to be just ban the player.
yeah u can do that i wouldnt ban i just wouldnt reward the hit
if its some kind of false positive it'll ruin the player experience
yeah but doesn't the player send the information of where the player should be and that hitbox on the same time right? So woulden't that not matter?
right u shouldnt be check where the hitbox is u should be checking where the player character is and use a magnitude check to see if its possible to hit them with their max speed
watch suphi's antiexploit video he goes over this
alright
oh something suphi didnt go over which i didnt know about was if they fall they can exceed the "maxspeed" u set
u can use raycasting to see if they are actually walking/running or if they are falling* use a different "max speed"
alright
you can use RaycastHitboxV4
for Bombs i would use the Roblox Explosion Instance , it's the easiest way to make a bomb
But doesnt ik have a unwanted visual effect and sound
take a look at shapecast if u want to use raycasting
or u could use touched
You can add another sound
Yeah but i already got my answer
And what you could do is try to make the explosion effect invisible by overriding it with another effect
Hitbox depend your game content, if you making game like Rogue Demon then use box hitbox.
Yes it depends on your game
One message removed from a suspended account.
One message removed from a suspended account.
correct
but read my message again
i said have the touch event in a localscript
One message removed from a suspended account.
and use a remote event to tell the server that you touched
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
if you have the touch event on the server side or you use remote events you must always check the position of parts using a antihack
One message removed from a suspended account.
One message removed from a suspended account.
unless the part is anchored or you set the parts network owner to nil
then you dont need to use a antihack
One message removed from a suspended account.
One message removed from a suspended account.
yes it will be
because it takes time for position data to travel the internet to the other clients computers
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Discord: https://discord.gg/bEn49K5JUt
Patreon: https://www.patreon.com/Suphi
Donate: https://www.roblox.com/games/7532473490
Documentation: https://create.roblox.com/docs/scripting/networking/client-server-model
0:00:00 - Intro
0:00:09 - Text File Replication
0:02:04 - Studio Replication
0:19:21 - Outro
One message removed from a suspended account.
One message removed from a suspended account.
local hit = workspace:GetPartBoundsInRadius(hand.Position, 4, overlapParams)
One message removed from a suspended account.
One message removed from a suspended account.
If you want to most optimal way
Let me see what options overlap params
1 option is to use collision groups
Another option is to put each characters hitbox in the filter and set to include
You don't want to generate the list every time you use the getparts function
One message removed from a suspended account.
You want to use characteradded and characterremoved to update the list
Another option if you want to detect hitting all parts of a character
Is put all the characters in a folder
And then set that folder as the filter
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
Yes
One message removed from a suspended account.
You do it on the server side
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
In Roblox a few years mesh editor plugin was my first project
One message removed from a suspended account.
Iv been programming since I was 12 years old
One message removed from a suspended account.
I'm almost 36 now
One message removed from a suspended account.
One message removed from a suspended account.
its not good to load the animation every time
also its not good to conect to a connection inside another connection unless your disconnecting
you could have a memory leak
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
local animation = script:WaitForChild("Animation")
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:GetMarkerReachedSignal("Hit"):Connect(function(paramString)
local hit = workspace:GetPartBoundsInRadius(rightHand.Position, 4, overlapParams)
if #hit == 0 then return end
local character = hit[1]:FindFirstAncestorOfClass("Model")
hitRemote:FireServer(character)
end)
userInputService.InputBegan:Connect(function(input, processed)
if processed == true then return end
if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
animationTrack:Play()
end)
One message removed from a suspended account.
One message removed from a suspended account.
also its better to do FindFirstAncestorOfClass on the client side
One message removed from a suspended account.
yes you need to have a antihack on the serverside
One message removed from a suspended account.
your antihack will not be able to know perfectly the hit position
so it will be within around 10 to 20 studs
so its safe to just use the rootposition
One message removed from a suspended account.
One message removed from a suspended account.
so if the hit position is within 10 to 20 studs server will accept it
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
local animation = script:WaitForChild("Animation")
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:GetMarkerReachedSignal("Hit"):Connect(function(paramString)
local hit = workspace:GetPartBoundsInRadius(rightHand.Position, 4, overlapParams)
if #hit == 0 then return end
local character = hit[1]:FindFirstAncestorOfClass("Model")
hitRemote:FireServer(character.Humanoid)
end)
userInputService.InputBegan:Connect(function(input, processed)
if processed == true then return end
if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
animationTrack:Play()
end)
hitRemote.OnServerEvent:Connect(function(player, humanoid)
if typeof(humanoid) ~= "Instance" or humanoid.ClassName ~= "Humanoid" then return end
local position1 = antiHack.GetPosition(player.Character.Humanoid.RootPart)
local position2 = antiHack.GetPosition(humanoid.RootPart)
local magnitude = (position2 - position1).Magnitude
if magnitude > 10 then return end
humanoid:TakeDamage(10)
end)
somthing like this
One message removed from a suspended account.
i have a video showing how to make a basic antihack module
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.
if typeof(humanoid) ~= "Instance" or humanoid.ClassName ~= "Humanoid" then return end
One message removed from a suspended account.
One message removed from a suspended account.
you can have variables in both the server and client
One message removed from a suspended account.
local animation = script:WaitForChild("Animation")
local animationTrack = humanoid:LoadAnimation(animation)
local combo = 0
animationTrack:GetMarkerReachedSignal("Hit"):Connect(function(paramString)
local hit = workspace:GetPartBoundsInRadius(rightHand.Position, 4, overlapParams)
if #hit == 0 then return end
local character = hit[1]:FindFirstAncestorOfClass("Model")
hitRemote:FireServer(character.Humanoid)
end)
userInputService.InputBegan:Connect(function(input, processed)
if processed == true then return end
if input.UserInputType ~= Enum.UserInputType.MouseButton1 then return end
animationTrack:Play()
end)
local combos = {}
hitRemote.OnServerEvent:Connect(function(player, humanoid)
if typeof(humanoid) ~= "Instance" or humanoid.ClassName ~= "Humanoid" then return end
local position1 = antiHack.GetPosition(player.Character.Humanoid.RootPart)
local position2 = antiHack.GetPosition(humanoid.RootPart)
local magnitude = (position2 - position1).Magnitude
if magnitude > 10 then return end
local combo = combos[player]
humanoid:TakeDamage(10)
end)
local function PlayerAdded(player)
combos[player] = 0
end
local function PlayerRemoved(player)
combos[player] = nil
end
One message removed from a suspended account.
they should stay in sync for non hackers
they can go out of sync for hackers but it wont have any effect
One message removed from a suspended account.
One message removed from a suspended account.
One message removed from a suspended account.