Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

add leaderstats value if player exploded?

alright so i have a script that clones a bomb into workspace but also a string value(Owner) and i am trying to figure out a way to make the game add leaderstat values to a player when they kill someone (for now it is set up in a way that a player can farm coins off themselfs but i will fix that later) but right now everything works fine but it doesnt add any values and yes this is a server script and yes the bomb is cloned serverside

also i new to messing around with explosions this is the first game ive ever messed with them

script:

local beep = script.Parent.beep
beep:Play()
beep.TimePosition = 0
wait(1.5)
beep:Play()
beep.TimePosition = 0
wait(1.5)
beep:Play()
wait(1.5)
local Explosion = Instance.new("Explosion")
Explosion.Parent = workspace
Explosion.Position = script.Parent.Position
Explosion.Hit:Connect(function(part,distance)
	if part.Name == "UpperTorso" or "LowerTorso" or "Head" or "HumanoidRootPart" or "LeftFoot" or "LeftLowerLeg" or "LeftUpperLeg" or "LeftLowerArm" or "LeftHand" or "LeftUpperArm" or "RightFoot" or "RightUpperLeg" or "RightLowerLeg" or "RightHand" or "RightUpperArm" or "RightLowerArm" or "RightHand" then
		local name = script.Parent.Owner.Value
		local player = game.Players:FindFirstChild(name)
		player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 50
	else
		script.Parent:Destroy()
	end
end)
script.Parent:Destroy()

4 comments

0

ok, you can do if game.Players:GetPlayerFromCharacter(part.Parent) instead of that long line of code checking the names

0

that also works for getting the player

0

Also, presuming that Coins is an int value, you need to do player.leaderstats.Coins.Value = ...

0

wow ok thanks man i didnt even realize i didnt put .Value and i had no idea about :GetPlayerFromCharacter() being able to grab Character Parts

1 answer

Hi, In your script i don't see any variables for the Coins to be Coins.Value, I believe that is the only issue

local Coins = player.leaderstats.Coins 

Coins.Value = Coins.Value + 50 

let me know!

1 comment

0

yeah i fixed that i forgot to update it and still nothing

This discussion is preserved as it was. New answers, comments, and votes are closed.