Info: Script is a localscript. Script is in StarterPack. Gui is in PlayerGui. ]] Guys I need help. This script is supposed to make the texto of a TextLabel change when a player dies.
local player = game.Players.LocalPlayer local humanoid = player.Character:FindFirstChild("Humanoid") local text = player.PlayerGui:WaitForChild("DeathGui").Background.Bar.DeathMessage local messages ={"You did your best!","Wait, whaat!?","It's ok!","You can't do better?","Don't give up!"} function changemessage() for i = 1,1 do for i,v in pairs(messages)do end local m = math.random(1,5) print(m) local text1 = messages[m] text.Text = text1 print(messages[m]) end end player.Character:FindFirstChild("Humanoid").Died:connect(function() player.PlayerGui.DeathGui.Background.Visible = true wait(.3) player.PlayerGui.DeathGui.Background.Bar:TweenSize(UDim2.new(0,800,0,200),"In","Linear",.1) wait(.1) changemessage() player.PlayerGui.DeathGui.Background.Bar.DeathMessage.Visible = true script.Fail:Play() end)
It Works once the player dies but the second time the player dies it won't change.. I don't know why. Anyone willing to help for some rep? I'd really apreciate it :C!
I have two things to say:
player.PlayerGui.DeathGui.Background.Visible = false
and/or
player.PlayerGui.DeathGui.Background.Bar.DeathMessage.Visible = false
;
for i = 1,1 do for i,v in pairs(messages)do
if you are going to do
local m = math.random(1,5)
and local text1 = messages[m]
I would just leave it like:
function changemessage() local m = math.random(1,5) print(m) local text.Text = messages[m] print(messages[m]) end
or
function changemessage() local text.Text = messages[math.random(1,5)] print(messages[m]) end