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)
You have multiple big mistakes in your code
StarterGui
is 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.
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)