Hello, I am having trouble figuring out a way to increase a value in a script in the player's ScreenGui. What I need to do is detect who the player is who dealt the lethal blow to the enemy (or even better, whoever dealt the most damage) and then increase their money value by an amount, but I really know how to detect if the enemy died or who killed it. Thanks.
EDIT: I'm going to post the code that I have for the player's balance of money.
local Players = game:GetService("Players")
local ThePlayer = nil
function onPlayerAdded(player)
ThePlayer = player
local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 166
Coins.Parent = script
if ThePlayer.PlayerGui.ScreenGui ~= nil then
ThePlayer.PlayerGui.ScreenGui.CoinAmount.Text = Coins.Value
end
end
--When a player joins, call the onPlayerAdded function
Players.PlayerAdded:connect(onPlayerAdded)
--Call onPlayerAdded for each player already in the game
for _,player in pairs(Players:GetPlayers()) do
onPlayerAdded(player)
end
while true do
script.Coins.Value = script.Coins.Value + 1
ThePlayer.PlayerGui.ScreenGui.CoinAmount.Text = script.Coins.Value
game.ServerStorage.CoinGet:Play()
wait(1)
end
For testing purposes, the amount of coins is increased by one every second.

2 comments
Not enough detail. Atleast post the script so we can modify it :/ come on dude, we aren't gods you know..
That's the problem, I don't have a script for this because I don't know how to do it, which is why I am asking.