Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Small change to script breaks the entire thing?

heya. I'm trying to make my startup screen for my MMORPG, and I realized that it starts again whenever I die/reset (something I don't want,obviously.)

I've made modifications to the script, including adding another local script in the StarterGUI, specifically to make sure that the GUI fires ONLY when the player joins the server, shown below.

game.Players.PlayerAdded:connect(function(plr)
	local startup = game.ReplicatedStorage.GUIs.startupScreen:Clone()
	startup.Parent = plr.PlayerGui
end)

Also, the GUI works as so. The GUI goes from invisible to visible using the transparency property in the GUI. I set it to trigger whenever the PlayerGUI is the GUI's parent. (Basically the GUI is in the player) However, when I join the game, it doesn't move to the playerGUI parent.

Here's the transparency script within the GUI if this would help any.

local player = game.Players.LocalPlayer
local parent = player.PlayerGui

if not parent then
	wait()
else
	for i = 1,0.5, -.01 do
		script.Parent.BackgroundTransparency = i	
		wait(.1)
	end
end

Thanks in advance.

2 comments

0

You destroy the GUI after the use, right?

0

Yep

3 answers

✓ Accepted answer

From what I can see, the problem lies in the script that controls the transparency. For the if not then function, your use of the variable "parent" would show up in the script like this, if it was not a variable.

if not game.Players.LocalPlayer.PlayerGui then
-- etc.

That does not tell the game what it is looking for. How I, personally would script that statement is

if not script.Parent == game.Players.LocalPlayer.PlayerGui  then -- Change parents to fit your needs.
-- etc.

because that tells the script you aren't looking for if PlayerGui Exists, but if your GUI's Parent is PlayerGui.

Also, Make sure you are using a LocalScript to run this.

1 comment

0

Thank you!

local player = game.Players.LocalPlayer
local parent = player.PlayerGui
game.workspace:FindFirstChild("Humanoid")
while true do
if humanoid and humanoid.Health == 0 then 
local parent = game.StarterGui
    end
end

try this tell me if it works or not

@Munter6000

Similar to what I needed, but not what I needed at the same time (by far.)

This discussion is preserved as it was. New answers, comments, and votes are closed.