Hey I’m working on a game that u throw dynamite and stuff but how would I track the kills since u throw dynamite how would I do that?? I have no ideas any ideas would be helpful thanks
Maybe use an ObjectValue inside the dynamite.
You can store the player that threw the dynamite.
I have tried something along those lines but wasn’t sure how to incorporate it I’ll try again thought ty
Here is a post that may be helpful:
I don’t see how this would help
When you say track the kills I assumed you meant the damage, since not every throw will kill.
If you want the “kill” then check if the hit player’s health is zero. Then record the kill for the player that threw the dynamite.
I don’t know how to do that…im too dumb
With the dynamite, you could use :SetAttribute()
to easily track the player that threw it. Just have something like: (when creating the dynamite)
dynamite:SetAttribute("ThrownPlayer", thrownPlayer.Name)
To reference which player threw the dynamite, just do
local attacker = game.Players[dynamite:GetAttribute("ThrownPlayer")]
Maybe check the tool box for a working grenade and see how they did it.
ill try this thanks for the response
here is the script in the tool how would I incorporate ur idea in this script this is in the tool btw
local tool = script.Parent
local cooldown = 3
local coolingDown = false
local explodesIn = 2
local char
tool.Equipped:Connect(function()
char = tool.Parent
end)
tool.Unequipped:Connect(function()
char = nil
end)
local mouseCF
tool.MouseInfoRE.OnServerEvent:Connect(function(plr, mouseHit)
mouseCF = mouseHit
end)
tool.Activated:Connect(function()
if coolingDown then return end
coolingDown = true
char.Humanoid:LoadAnimation(script.ThrowAnim):Play()
wait(0.3)
local clone = tool.Handle:Clone()
clone.Attachment.Fire.Enabled = true
clone.Name = "DynaMite"
clone.Sound:Play()
tool.Handle.Transparency = 1
local bv = Instance.new("BodyVelocity")
bv.Velocity = mouseCF.LookVector * 75
bv.Parent = clone
clone.Parent = workspace
clone.CanCollide = true
local explodeCoro = coroutine.wrap(function()
wait(explodesIn)
local explosion = Instance.new("Explosion")
local sound = clone.ExplodeSound
explosion.BlastRadius = 7
explosion.TimeScale = 3
explosion.Position = clone.Position
explosion.DestroyJointRadiusPercent = 100
explosion.Parent = clone
explosion.BlastPressure = 10000000
explosion.Visible = false
sound:Play()
explosion.Parent = game.Workspace
sound.Parent = game.Workspace
local newppart = game.Workspace:FindFirstChild("DynaPart")
newppart.Anchored = true
newppart.Transparency = 0.5
newppart.Position = clone.Position + Vector3.new(0,5,0)
local emit = Instance.new("ParticleEmitter")
emit.Enabled = true
emit.Parent = game.Workspace.DynaPart
emit.Texture = "rbxassetid://405886187"
clone:Destroy()
wait(1.5)
explosion:Remove()
sound:Remove()
end)
explodeCoro()
wait(0.1)
bv:Destroy()
wait(cooldown - 0.2)
game.Debris:AddItem(clone,2)
tool.Handle.Transparency = 0
coolingDown = false
end)
If you don’t mind, could I also see the LocalScript side of this? (If you don’t wanna share publicly I get it, you can also PM me if you don’t wanna share it)
When the player throws the dynamite, give it an attribute called “Player” with the value being the player instance or name (whatever you choose is fine)
You can do this by writing dynamite:SetAttribute("Player", player)
Then when the other person is hit, check the initial person who threw it by doing:
local thrownPlayer = dynamite:GetAttribute("Player")
and you can award kills by presumably doing
thrownPlayer.leaderstats.Kills.Value += 1