Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making an int value appear in a TextBox?

I tested some things for FE and I need the int value to appear with the text. Can someone explain to me why this wouldn't work?

Script

local Int = game:GetService("ReplicatedStorage"):WaitForChild("Int")
local b = game:GetService("ReplicatedStorage"):WaitForChild("Bint")

game.ReplicatedStorage.houg.OnServerEvent:Connect(function(Int, b)
script.Parent.TextLabel.Text = "sad = "..Int.Value
end)

Local Script

local houg = game.ReplicatedStorage.houg

houg:FireServer()

1 comment

0

Waht is the server modifying PlayerGui? It has no business there, the client should handle all the GUI.

2 answers

The first argument "Int" is classified as the player who fired the event. You cannot do player.Value, since the player's username isn't a value. Also, you need to add an argument to where it says "FireServer()" or remove the "b" part from the OnServerEvent arguments.

You cannot concatenate string values with int values, to overcome this obstacle you must use the very helpful tostring() function, it works oppositely as tonumber(), you should do your script like this.

local Int = game:GetService("ReplicatedStorage"):WaitForChild("Int")
local b = game:GetService("ReplicatedStorage"):WaitForChild("Bint")

game.ReplicatedStorage.houg.OnServerEvent:Connect(function()
	thestring = tostring(Int.Value)
	script.Parent.TextLabel.Text = "sad = "..thestring
end)

The first "Int" and "b" part should both be in the localscript and if you don't want this to happen simply remove the "Int" and "b" arguments in your function like I done above, because if this were to happen, in reality you would be doing "Player.Value"

Also it's good practice to add indents into your scripts to identify which part is which. ~tantec

1 comment

0

You should have also specified that the server should NOT be modifying GUI.

This discussion is preserved as it was. New answers, comments, and votes are closed.