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

It does not remove the ScreenGui?

I want it to wait (7) before getting removed

Startposition=script.Parent.Position

while true do
    local RightBorder=script.Parent.AbsolutePosition.X+script.Parent.AbsoluteSize.X
    if RightBorder<=0 then
        script.Parent.Position=Startposition
    else
        script.Parent.Position=script.Parent.Position-UDim2.new(0.005,0,0,0)
    end
    wait()
end
wait(7)
game.Workspace.StarterGui.ScreenGui:Remove()

2 answers

✓ Accepted answer

Your problem is that you're trying to remove it from the StarterGui (Also, you tried to use game.Workspace.StarterGui, the StarterGui is accessed via game.StarterGui). When a player joins the game, everything gets copied from the StarterGui, into the Player's PlayerGui.

Therefore, to affect anything that the player will actually see, you need to adjust it through the PlayerGui.

Another problem I noticed you have, is that you're running an infinite loop. To fix this, we'll switch things up a bit, and have a timer set for 7 seconds.


To fix your script, we'll simply find the LocalPlayer, and access their PlayerGui. If this isn't already in one, put it in a LocalScript:

local Plr=game.Players.LocalPlayer --Got the player
local Startposition=script.Parent.Position
local Starttime=os.time()

while true do
	local RightBorder=script.Parent.AbsolutePosition.X+script.Parent.AbsoluteSize.X
	if RightBorder<=0 then
		script.Parent.Position=Startposition
	else
		script.Parent.Position=script.Parent.Position-UDim2.new(0.005,0,0,0)
	end
	wait()
	if os.time()-Starttime>=7 then --Checks if it's been 7 seconds yet.
		Plr.PlayerGui.ScreenGui:Remove() --Deleted it from PlayerGui
	end
end

So now this should work if you had everything else correct, which it seems you do.


Anyways, if you have any further problems/questions, please leave a comment below. Hope I helped :P

####-Dyler3

3 comments

0

Does not get removed in 7 seonds.

0

Should be fixed now :P

0

It be fixed now :P

Hi I see an error..

Game.Workspace.StarterGui.ScreenGui:Remove()

That's what u put u said starter GUI was in workspace

game.StarterGui.ScreenGui:Remove()--is what u need to put

Hope this helped!

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