Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 3 years ago

this is basically the question

2 answers

Log in to vote
0
Answered by 3 years ago

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! :)

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 Iownrobloxp 44 — 3y
0
also thanks for the answer :) Iownrobloxp 44 — 3y
0
also the issue could be that I put it in server script service and that its a local script? Iownrobloxp 44 — 3y
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. NinjaMandalorian 252 — 3y
View all comments (2 more)
0
thanks I ended Up fixing it, is it possible to accept two answers because both of you guys helped me alot? Iownrobloxp 44 — 3y
0
i do not believe so NinjaMandalorian 252 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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:

0
Thanks for the answer you helped me along with the other person, again thanks you two Iownrobloxp 44 — 3y
0
No problem bro :thumbs_up: bily117 6 — 3y

Answer this question