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

When I'm resizing a GUI via script this happens, why?

Asked by
Audiimo 105
7 years ago
Edited 7 years ago

I'm practicing scripting and I am adding a feature where a GUI pops up when a player has joined. I am also using the script to resize it and when I do so this message pops up "No method name passed in __namecall for UDim2"

Here is my script. Can someone tell me what's wrong? I have tried looking for answers and attempting fixes but the same thing has happened.

game.Players.PlayerAdded:Connect(function(player)
    Instance.new("ScreenGui", game.StarterGui)
    local t = Instance.new("TextBox", game.StarterGui.ScreenGui)
    t.Size = UDim2.new(300,0)(100,0)
end)

2 answers

Log in to vote
2
Answered by
lukeb50 631 Moderation Voter
7 years ago
Edited 7 years ago

You have multiple big mistakes in your code

StarterGuiis what contains GUIs that are to be sent to the player when they join/die. It will not show on their screen until they die and it is shared between clients.

You should instead make changes inside game.Players[PlayerName].PlayerGui, as this is where the GUIs they have and can see are.

Line 1 suggests that this is a script. The PlayerGui is not visible to the server and is only viewable by the client, despite this not being the case in studio. All GUI manipulations should happen in localscripts on the client. FE has NO effect on this on a real server.

Despite what the wiki tells you, creating all your GUIs at runtime via scripts is NOT good or even acceptable practice. Create them in studio before.

UDim2s are formatted like this: XScale,XOffset,YScale,YOffset. Scale is based on the screen size and Offset is pixels. Your UDim2 is 300 times the size of the screen on X and 100 times on Y.

0
dude. You didn't even see the main mistake... ._. greatneil80 2647 — 7y
0
I did but it's so irrelevant compared to the bigger stuff lukeb50 631 — 7y
0
How do I specify a person without knowing the name? i know its like player.Name but when I write in the code it thinks i'm specifying a child. How do I get around this? Audiimo 105 — 7y
Ad
Log in to vote
0
Answered by 7 years ago

UDim2 only needs one set of parentheses. Also, you're making the GUI inside of StarterGui which I don't think will replicated once the player joins, you want to change it to PlayerGui if FE is off

game.Players.PlayerAdded:Connect(function(player)
    Instance.new("ScreenGui", player.PlayerGui)
    local t = Instance.new("TextBox", player.PlayerGui.ScreenGui)
    t.Size = UDim2.new(300,0,100,0)
end)
0
Thank you so much! Audiimo 105 — 7y

Answer this question