game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
if true then
local titleScroll = plr.PlayerGui:WaitForChild("TitlesGui"):WaitForChild("TitlesFrame"):WaitForChild("TitlesScroll")
titleScroll:WaitForChild("StarterTitleFrame"):WaitForChild("EquipButton").MouseButton1Click:Connect(function()
if true then
local leaderstats = plr.leaderstats
if leaderstats.kills.Value > 0 and leaderstats.wins.Value > 0 then
local starterTitle = titles.StarterTitleGui:Clone()
local originalTitle = char:WaitForChild("Head"):FindFirstChildWhichIsA("BillboardGui")
if originalTitle then
originalTitle:Destroy()
end
starterTitle.Parent = char:WaitForChild("Head")
plr.CharacterAdded:Connect(function(newChar)
if true then
task.wait(0.5)
local starterTitle2 = titles.StarterTitleGui:Clone()
local originalTitle2 = newChar:WaitForChild("Head"):FindFirstChildWhichIsA("BillboardGui")
if originalTitle2 then
originalTitle2:Destroy()
end
starterTitle2.Parent = newChar:WaitForChild("Head")
end
end)
titleScroll.StarterTitleFrame.EquipButton.Text = "Equipped"
task.wait(3)
titleScroll.StarterTitleFrame.EquipButton.Text = "Equip"
else
plr.PlayerGui.AntiEquipGui.Enabled = true
task.wait(3)
plr.PlayerGui.AntiEquipGui.Enabled = false
end
end
end)
end
end)
end)
how can i transform this script so that it runs more than once? ive tried making it a while loop, that didnt work
edit: to clarify, i want this script to run whenever the player dies (NOT when the player respawns however)
I don’t know about the if true then statement is that really necessary?
anyway just saying. Have you tried to print in every statement so you can see which one is acting wrong?
tried that. apparently it went wrong at the introduction of the titleScroll. theres an output error, saying startertitleframe is not the child of titlescroll, when it is??? theres nothing else named “startertitleframe” either
huh weird at least we know why it didn’t loop.
And i think this is a server script which can not reach to player gui
You should fire an event when button pressed instead
Edit: I see people still able to do it on server side and they add Player:WaitForChild(“PlayerGui”) instead of Player.PlayerGui
Tried cleaning your script in hopes of fixing it, good luck:
--LocalScript inside game.StarterPlayer.StarterCharacterScripts
local titles = --path to titles
local Character = script.Parent
local Player = game.Players.LocalPlayer
local UI = Player:FindFirstChildWhichIsA("PlayerGui")
local frame = UI:WaitForChild("TitlesGui"):WaitForChild("TitlesFrame"):WaitForChild("TitlesScroll"):WaitForChild("StarterTitleFrame")
frame:WaitForChild("EquipButton").MouseButton1Click:Connect(function()
if Player.leaderstats.kills.Value > 0 and Player.leaderstats.wins.Value > 0 then
local Head = Character:WaitForChild("Head")
local originalTitle = Head:FindFirstChildWhichIsA("BillboardGui")
if originalTitle then originalTitle:Destroy() end
titles.StarterTitleGui:Clone().Parent = Head
frame.EquipButton.Text = "Equipped"
task.wait(3)
frame.EquipButton.Text = "Equip"
else
UI.AntiEquipGui.Enabled = true
task.wait(3)
UI.AntiEquipGui.Enabled = false
end
end)