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

It does not remove the ScreenGui?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

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

Log in to vote
2
Answered by
dyler3 1510 Moderation Voter
8 years ago

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

0
Does not get removed in 7 seonds. FiredDusk 1466 — 8y
0
Should be fixed now :P dyler3 1510 — 8y
0
It be fixed now :P FiredDusk 1466 — 8y
Ad
Log in to vote
1
Answered by
iSvenDerp 233 Moderation Voter
8 years ago

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!

Answer this question