-
What do you want to achieve?
I want to use a Local Script to detect for Character Collision in a part for a “Gradual Health Reduction system” -
What is the issue?
My current system detects collisions but the hitboxes are semi-broken, the character hits the collision hitbox but it sometimes doesn’t reduce the stat.
1 Like
if collisions are the issue then I don’t think the script is the problem, it’s probably the part itself. roblox is kinda known for awful collision boxes when it comes to unions and meshes so if it involves any of that then that could be the issue.
2 Likes
All hitboxes are block parts, do you want me to send the script for the collision detection?
It would really help if you sent the code that detects the collision.
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local C = player.Character or player.CharacterAdded:wait(1)
local H = C:WaitForChild("Humanoid")
local area = game.Workspace.KillElements
local toggle = false
while true do wait(0.05)
for i, section in pairs(area:GetChildren()) do
local pos1,pos2 = (section.Position - (section.Size / 2)),(section.Position + (section.Size / 2))
local region = Region3.new(pos1,pos2)
local playersFound = game.Workspace:FindPartsInRegion3(region)
for i, playersInArea in pairs(playersFound) do
if playersInArea:FindFirstAncestor(player.Name) then
toggle = true
if section.Name == "SlowDamage" and script.Parent.hasStarted.Value == true then
script.Edibility.Value = script.Edibility.Value - 0.15
elseif section.Name == "MediumDamage" and script.Parent.hasStarted.Value == true then
script.Edibility.Value = script.Edibility.Value - 0.3
elseif section.Name == "FastDamage" and script.Parent.hasStarted.Value == true then
script.Edibility.Value = script.Edibility.Value - 0.6
elseif section.Name == "InstantKill" and script.Parent.hasStarted.Value == true then
script.Edibility.Value = 0
end
wait(0.05)
else
toggle = false
end
end
end
end
I don’t know if this code is efficient.