✓ 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
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
Plr.PlayerGui.ScreenGui:Remove()
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
Does not get removed in 7 seonds.
Should be fixed now :P
It be fixed now :P