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

What is wrong with this script?

Asked by 10 years ago

I made a simple script that is the base for thing later on, this script clones a GUI in a tool into PlayerGui but it didn't work. And there was no error either! so i couldn't solve the problem. Here is the script:

function Show()
    cloned = script.Parent:Clone()
    cloned.Parent = game.Players.Player1.PlayerGui
end
while true do
    Show()
end

1 answer

Log in to vote
0
Answered by 10 years ago

This script is a recipe for crashes. Currently it keeps cloning this script to the PlayerGui and from there the cloned scripts start cloning themselves too. I'd create a script with something like this.

function Show(player)
    local clone = game.ServerStorage.Script:Clone()
    clone.Parent = player.PlayerGui
end

game.Players.PlayerAdded:connect(Show(player))

Then put the script you want to copy into the ServerStorage and change it in the script. This way it will only run once. And if you want it to do it everytime a player spawns. Use the following script.

function Show(player)
    local clone = game.ServerStorage.Script:Clone()
    clone.Parent = player.PlayerGui
end

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(Show(player))
end)
0
What if he needs to do that for everytime he spawns? The PlayerGui resets to what is inside the StarterGui each time you respawn. Spongocardo 1991 — 10y
0
If he needs to run that script everytime someone spawns, then he has to make his question more specific. It's that simple. Edit: I added another script that does it on each respawn. damagex443 325 — 10y
0
It didn't work right away but with a few upgrades it worked well :) vectorxray 5 — 10y
Ad

Answer this question