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

why does my ScreenGui only pop up when i die, it even pops up in the wrong spot..?

what the script is supposed to do is when i press "R" it will remove my humanoid and then make me respawn after 3 seconds, which it does. But it's also supposed to make this ScreenGui pop up saying "YOU FOOL" but it only pops up after i respawn. It even puts it in the wrong spot! Please help me if you know the answer to my problem and my script is:

local UIS = game:GetService('UserInputService')
local player = game.Players.LocalPlayer

UIS.InputBegan:Connect(function(input, poo)
	if poo then return end
	if input.KeyCode == Enum.KeyCode.R then
		local hum = player.Character:WaitForChild('Humanoid')
		if hum ~= nil then
			game.StarterGui.youfool.TextLabel.Position = UDim2.new({0.384, 0},{0.409, 0})
			wait(0.1)
			hum:Destroy()
			wait(3)
			player:LoadCharacter()
		end
	end
end)

and yes i put the ScreenGui in the right place for the script

it also is a local script

3 comments

0

Yes, I'm new to scripting, and I'm not sure if it pops up on just one client or the whole server. If you know if it pops up on the whole server or client, please tell me and I want it just to pop up on the client's screen (the person who pressed R)

0

About the "ScreenGui only pops up when i die", there's a setting in the gui itself, it toggles if the gui resets when the player respawns. It's called "ResetOnSpawn". You can toggle that so your gui doesn't appear on death.

0

okay, thanks!

1 answer

For your first problem This is because you assume that the gui is still in the startergui, wich isn't the case.

Well, kinda, it gets cloned to the player, so what happends it, you change the gui, when the player dies, it gets cloned again, and the positions changes

It gets cloned to the playergui, so it would end up something like this (line 9) player:WaitForChild('PlayerGui').youfool.TextLabel.Position = UDim2.new({0.384, 0},{0.409, 0})

For your second problem I saw that you used size for the size, so that part is right, so you probably used offset for the position, I don't know this though, so I can't answer that, if you can't solve it add a screenshot or so from the location, the place, and the properties (size and position)

If you have any more questions, just ask

(Also, if ... ~= nil then isn't neccesary, it's the same as if ... then)

EDIT (after reading your comment)

It depends on if you're using FE or not

Without FE: It would change for every player, as the contents of startergui get cloned to the playergui for every player

With FE: It would change for you, as local scripts cannot change things in the server (without the use of remotes)

6 comments

0

okay and yes, it is FE.

0

okay, thank you so much. The ScreenGui did pop up and one of my friends helped me with the position problem. Thanks!

0

Np, can you accept the answer?

0

Okay, how?

0

There should be an accept answer button under the answer

0

Weird, I don't see it..

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