You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
how would i detect if a player was killed by an explosion and then tag the person who created the explosion
What is the issue? Include screenshots / videos if possible!
i tried following multiple tutorials and looking online, but i am in a slightly different situation, because how my script works is that when you activate a proximity prompt a cloned ball from replicatedstorage will go from one part to another part then explode on touched through another script inside the cloned ball
i am a beginner/novice scripter but am not new to roblox studio
I’m not sure how to tell it was an explosion unless it happen inside the player or was part of the
explosion script. But this is how you can tell they died … two versions.
--a ServerScript in ServerScriptService
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.Humanoid.Died:Connect(function()
-- they died
end)
end)
end)
--a LocalScript in StarterGui or
--StarterPlayer.StarterPlayerScripts
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
-- they died
end)
Have the default ROBLOX explosion do no damange, and create your own explosion damage script. In that DIY script you can include an identifier that goes to the player when it kills them.
I don’t think that the default .Hit event inside of explosions can identify themselves as explosions, which is what OP is asking. I could be wrong though.
Since projectiles/explosions get destroyed, you may need to get its creator tag name as sooner you can, or the properties like Instance.Name or Attributes will not be available.
You can also try to:
local function RegisterAttacker(Attacker, Target, Callback, Params)
local CreationTime = tick()
local ValidTimeThreshold = 20
local LatestAttacker = Target:FindFirstChild("LatestAttacker") or Instance.new("ObjectValue")
LatestAttacker.Name = "LatestAttacker"
LatestAttacker.Value = Attacker
LatestAttacker.Parent = Target
game.Debris:AddItem(LatestAttacker, ValidTimeThreshold)
LatestAttacker.Destroying:Once(function()
if CreationTime + ValidTimeThreshold < tick() then return end
Params = Params or {}
Callback(Params) -- will be executed before the Character destruction
end)
end
local explode = Instance.new("explosion") -- change it idk
explode.Hit:connect(function(PartTouched, Radius)
if PartTouched.Parent:FindFirstChildOfClass("Humanoid") then
local char = PartTouched.Parent
local hum = char:FindFirstChildOfClass("Humanoid")
if hum.Health == 0 then
print("Dada") -- what happens if someone died
end
end
end)
thanks for the recommendations except, the only part that im really having problems on is tracing the guy who died to person who activated the proximity prompt and then creator tagging it
Have you tried to do a boxcast in the explosion radius?
Try it. I’m waiting for the results
local function GetDeadCharactersByExplosion(Explosion, FilteredInstances)
-- Part
local Sphere = Instance.new("Part")
Sphere.Size = Vector.one * Explosion.BlastRadius
Sphere.Position = Explosion.Position
Sphere.Anchored = true
Sphere.Shape = Enum.PartType.Ball
Sphere.Parent = workspace
-- Params
local Params = OverlapParams.new()
Params.FilterType = Enum.RaycastFilterType.Exclude
Params.FilterDescendantsInstances = FilteredInstances:IsA("Instance") and {FilteredInstances} or FilteredInstances
Params.CollisionGroup = "Default" -- or an especific
-- Detections
local Deaths = {}
local Detections = workspace:GetPartsInPart(Sphere, Params)
for i, part in ipairs(Detections) do
local character = part.Parent
local humanoid = character:FindFirstChild("Humanoid")
if not humanoid then continue end
if humanoid:GetState() == Enum.HumanoidStateType.Dead then continue end
humanoid.HealthChanged:Once(function(health)
if health <= 0 then table.insert(Deaths, character) end
end)
end
-- [Excute Explosion Here] --
return Deaths
end
OverlapParams is there to mask/filter out the thing that you don’t want, and the thing that you wants to be there
FilterType of Exclude → Excludes/Ignores the assigned descendants
FilterType of Include → Only accepts the assigned descendants
CollisionGroup specifies the CollisionGroup you want to perform the query on, this is somewhat identical to the filters
Performs a Spatial Query on the Sphere, which is just checking anything that overlaps the sphere.