This is what I mean, it isn't working, is it because of the way I stored the player?
local player = game.Players.LocalPlayer
while true do
if script.Parent.Generator.Health <= 0 then
script.Parent:Destroy()
player.PlayerGui:FindFirstChild("Gui")
local gui = script.Parent.Gui:Clone()
gui.Parent = player.PlayerGui
end
wait()
end

3 comments
Is it in a local script?
Server script,
You're going to need to use a LocalScript for the LocalPlayer part. If whatever else you're trying to do is supposed to happen on the server side, you're going to have to use a RemoteEvent, fire it from the LocalScript, and pick up the signal from a server Script.