Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make changed text stay after the charecter dies/respawns? This script is in part.

Asked by 3 years ago
Edited 3 years ago
script.Parent.Touched:Connect(function(plr)
        if plr.Parent:IsA("Model") and game.Players:FindFirstChild(plr.Parent.Name) then
            if game.Players:GetPlayerFromCharacter(plr.Parent) then
                plr=game.Players:GetPlayerFromCharacter(plr.Parent)
                plr.PlayerGui.Service.PortalsFrame.Winterland.Text = "Teleport"
                plr.PlayerGui.Service.PortalsFrame.Winterland.BackgroundColor3 = Color3.fromRGB(62, 255, 33)
            end
        end
    end)

1 answer

Log in to vote
0
Answered by
EmK530 143
3 years ago

If you don't plan to change the text back, you can make a permanent solution in the same script by editing the ui again everytime the player respawns.

As always, let me know if it works or if it is broken, yet again I can't test.

local players={}

script.Parent.Touched:Connect(function(plr)
    if plr.Parent:IsA("Model") and game.Players:FindFirstChild(plr.Parent.Name) then
        if game.Players:GetPlayerFromCharacter(plr.Parent) then
            plr=game.Players:GetPlayerFromCharacter(plr.Parent)
            if table.find(players,plr.Name) == nil then
                table.insert(players,plr.Name)
                plr.CharacterAdded:Connect(function()
                    wait(0.25) -- You can try removing this wait line if you want, it's just me making sure it doesn't change too fast
                    plr.PlayerGui.Service.PortalsFrame.Winterland.Text = "Teleport"
                    plr.PlayerGui.Service.PortalsFrame.Winterland.BackgroundColor3 = Color3.fromRGB(62, 255, 33)
                end)
            elseif game.Players:FindFirstChild(plr.Name) == nil then
                table.remove(players,table.find(players,plr.Name))
            end
            plr.PlayerGui.Service.PortalsFrame.Winterland.Text = "Teleport"
            plr.PlayerGui.Service.PortalsFrame.Winterland.BackgroundColor3 = Color3.fromRGB(62, 255, 33)
        end
    end
end)
Ad

Answer this question