I’m trying to make it so when a boss in the workspace named “normalDETRIMENT” dies each player gets awarded 200 Lunar Coins. (i.e. lunar coins are part of a leaderstat which is [“Lunar Coins”]) I made a script to do this… but it doesn’t do anything. Nothing is printed in the console or returned when the boss dies. Here is the script I made
local function awardLunarCoins(player)
local leaderstats = player:WaitForChild("leaderstats")
local lunarCoins = leaderstats:FindFirstChild("LunarCoins")
if lunarCoins then
lunarCoins.Value = lunarCoins.Value + 200
end
end
local function onCharacterDied(character)
local humanoid = character:FindFirstChildOfClass("Humanoid")
if humanoid and humanoid.Health <= 0 and character.Name == "normalDETRIMENT" then
for _, player in ipairs(game.Players:GetPlayers()) do
awardLunarCoins(player)
end
end
end
I’m wondering what’s causing this to not work, and I still haven’t found any ideas of which they make it stop working