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

How do I fix this Local script in screenGui GUI? There is no error code what?

Asked by 4 years ago
while true do
    --point Create
    local Point = Instance.new("TextButton")
    Point.Parent = game.StarterGui.ScreenGui
    Point.Visible = true
    Point.Size = UDim2.new(0, 50, 0, 50)
    --color
    Point.BackgroundColor3 = Color3.new(255/255, 255/255, 255/255)
    --Location
    local xPos = math.random(23,1840)
    local yPos = math.random(180, 950)
    Point.AnchorPoint = Vector2.new(xPos, yPos)
    Point.Position = UDim2.new(0, xPos, 0, yPos)
    print("x : ",xPos," y : ",yPos)
    --delete
    wait(5)
    Point.MouseButton1Click:Connect(function()
    Point:Remove()
end)
end

This is my script there is no error or error code. So what's the problem you might ask. Well the TextButton is generated in the ScreenGui but it is not showing up. I tried to set the code to white as you can see but it won't show up. This is the URL to the picture of the TextBox how it is looking.

https://lh3.googleusercontent.com/-P6fU1D46MqY/XqPJcRWPO3I/AAAAAAAAA34/NF-L479cD3Uh2JBID_DvRJoxN-WkqVJXwCK8BGAsYHg/s0/2020-04-24.png

So like you saw the box is still there and will appear when you click it. But it won't show up. Please help me...

0
Make sure visible is set to true. JesseSong 3916 — 4y
0
And make sure on line 4 that startergui is playergui. That's because if you put it startergui it doesn't actually update until you reset or game starts JesseSong 3916 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Mabye you can change the Instance.new() to game:GetService()

I don't actually know. This is just a theory. I hope I helped.

Sincerely,

Ducksneedhelp - Scripting Noob

0
Wdym JesseSong 3916 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

Hello! I have an answer to your question. I had problem with that too, once. So basically, when you add an object to starter GUI, it doesn't actually update the player's GUI. Here is how to fix it:

local player = game.Players.LocalPlayer -- The player that has this script. 
while true do
    --point Create
    local Point = Instance.new("TextButton")
    Point.Parent = player.PlayerGui -- Changed this to PlayerGui
    Point.Visible = true
    Point.Size = UDim2.new(0, 50, 0, 50)
    --color
    Point.BackgroundColor3 = Color3.new(255/255, 255/255, 255/255)
    --Location
    local xPos = math.random(23,1840)
    local yPos = math.random(180, 950)
    Point.AnchorPoint = Vector2.new(xPos, yPos)
    Point.Position = UDim2.new(0, xPos, 0, yPos)
    print("x : ",xPos," y : ",yPos)
    --delete
    wait(5)
    Point.MouseButton1Click:Connect(function()
    Point:Remove()
end)
end

Your problem was that you added it into the starter GUi, which only shows up when the game starts or the player resets. So, to fix that, use the current player's GUI. Which is player.PlayerGui

Answer this question