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

How to add +1 to a local value when a player/ dummy dies?

this is basically the question

2 answers

You can easily achieve this by having a .Died event connected to a function which simply adds one, and connecting that event to every humanoid you want to count for.

E.G.

local Folder = workspace.Dummies

for i,part in pairs(Folder:GetDescendants()) do
	if part:IsA("Humanoid") then
		part.Died:Connect(function()
			--Whatever your counter system is
		end)
	end
end

Hope this helps! :)

6 comments

0

thanks for the answer but for some reason it didint work, i tried it on a dummy and I changed the local script and added this on line 6 Coin +=1 game.StarterGui.ScreenGui1212.TextLabel.Text = 'Coin: '..Coin

0

also thanks for the answer :)

0

also the issue could be that I put it in server script service and that its a local script?

0

You should not reference it through the starter gui. If it's on the client side, use a local script inside of the gui, and do script.Parent to reference the GUI. DOing game.StarterGui does not get the individual player's UI. Also, use a local script.

0

thanks I ended Up fixing it, is it possible to accept two answers because both of you guys helped me alot?

0

i do not believe so

So put this in a local script

local RS = game:GetService("ReplicatedStorage
local Players = game:GetService("Players")
local Player = Players.LocalPlayer
local Human = Player.Humanoid -- or something I cant remember get the humanoid here tho

if Human.Health == 0 then
	Player.LeaderStats.Coins = Player.LeaderStats.Coins + 1
end

something like that its a rough draft but gives u a very good idea at what I'm getting at :thumbs_up:

2 comments

0

Thanks for the answer you helped me along with the other person, again thanks you two

0

No problem bro :thumbs_up:

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