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

Making an int value appear in a TextBox?

Asked by
zmonds 7
6 years ago

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()
0
Waht is the server modifying PlayerGui? It has no business there, the client should handle all the GUI. User#19524 175 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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.

Ad
Log in to vote
0
Answered by
tantec 305 Moderation Voter
6 years ago
Edited 6 years ago

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

0
You should have also specified that the server should NOT be modifying GUI. User#19524 175 — 6y

Answer this question