First and foremost, I’d like to address that I’m not making a hitbox for a weapon or item that gets triggered when it hits a player. Quite the opposite, actually. Im trying to make a hitbox similar to minecraft (image ref below), where a box is parented to each player, so that its position corresponds with that of the player. So when raycasting, I can just check if it hits the hitbox instead of the player’s body.
I also want to make sure they can’t be exploited, so maybe create it from the server? If anyone cud pitch some ideas or advice, it wud b greatly appreciated.
local Players = game:GetService('Players')
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local HumanoidRootPart = Character:WaitForChild('HumanoidRootPart')
local Part = Instance.new('Part')
Part.Name = 'Hurtbox'
Part.Size = Vector3.new(3.5,5,2) -- You may change this
Part.CanCollide = false
Part.Transparency = 0.5 -- Make transparent if you need to
Part.CFrame = HumanoidRootPart.CFrame -- You may experiment with this because it can be placed wrong
local Weld = Instance.new('WeldConstraint')
Weld.P0 = Part
Weld.P1 = HumanoidRootPart
Part.Parent = Character
Weld.Parent = Part
end)
end)
After that you may try to do a whitelisted raycast (whitelist = hurtbox) and… i guess it will work.
I dont think so. It’s serversided, so i guess its fine. You can only delete part for yourself using exploit, it won’t affect the actual raycast, unless it is on clientside.
Yes I thought of tht, that’s why i made this post basically, but if u parent it to the plr, is it still exploitable? If yes, wts the best idea to solve this?