local Players = game:GetService("Players") local plr = game.Players.LocalPlayer local frames = script.Parent local function onCharacterDespawned(player) frames.PlayerName = player.Name .. " Has been killed" print("Working 2!") end local function whenYouDie(player) plr.CharacterRemoving:connect(function() onCharacterDespawned(player) print("Working!") end) end
Been trying random things for 2hrs, nothing works.
Its inside the starterGUI folder in a local script, inside of the frame itself.
I want the textLabel to call out the name, of the person who just died.
Thanks in advance.
You never call the function in the script, for a function to run you must call it after defining it.
All you do is defining without calling them.
Proper example of a function:
local function sayHello() print("Hello") end --defining it sayHello() -- calling it --> Output: 'Hello'
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) local humanoid = char:WaitForChild("Humanoid") if humanoid then humanoid.Died:Connect(function() print(plr.Name.." has died") --Here put the gui stuff end) end end) end)
Lol this made it work aswell. But would be much cooler, if i could make it work in the localscript...
game.Players.PlayerAdded:Connect(function(player) player.CharacterRemoving:Connect(function(character) print(player.Name .. " died due to ????") script.Parent.Parent.StarterGui.LastKilled.Frame.PlayerName.Text = player.Name .. " Just died!" end) end)