Basically I have a RemoteEvent that adds whatever number your textbox.text = to your IntValue but it’s not working properly. The intvalue just stays at 0. What am I doing wrong?
Remote Code:
local ageEvent = game:GetService("ReplicatedStorage").Events.Age
ageEvent.OnServerEvent:Connect(function(player)
player.Stats.Age.Value = player.PlayerGui.Menu.CharacterFrame.TextBox.Text
end)
TextButton Code:
local remote = game:GetService("ReplicatedStorage").Events.Age
local TextBox = script.Parent.CharacterFrame.TextBox
script.Parent.CharacterFrame.Submit.MouseButton1Down:Connect(function()
local number = tonumber(TextBox.Text)
if number <40 then
script.Parent.CharacterFrame.Visible = false
script.Parent.MainFrame.Visible = true
remote:FireServer()
elseif number >40 then
print("not acceptable")
end
end)
+1 -1 button code:
local Addone = script.Parent.AddOne
local RemoveOne = script.Parent.RemoveOne
local TextBox = script.Parent.TextBox
Addone.MouseButton1Down:Connect(function()
TextBox.Text = TextBox.Text +1
end)
RemoveOne.MouseButton1Down:Connect(function()
TextBox.Text = TextBox.Text -1
end)
I believe you have to fire with arguments as the text is in the gui locally to send the information, and so the server won’t know what’s in the clients text box.
This is happening because the client is changing the Text on the TextBox, not the server. You are trying to get TextBox.Text on the server, which will return 0. A way to fix this, would be by doing this:
script.Parent.CharacterFrame.Submit.MouseButton1Down:Connect(function()
local number = tonumber(TextBox.Text)
if number <40 then
script.Parent.CharacterFrame.Visible = false
script.Parent.MainFrame.Visible = true
remote:FireServer(TextBox.Text)
elseif number >40 then
print("not acceptable")
end
end)
local ageEvent = game:GetService("ReplicatedStorage").Events.Age
ageEvent.OnServerEvent:Connect(function(player,age)
player.Stats.Age.Value = age
end)
This should fix this. If it did, I’d love for you to mark this message as the solution.
The real issue is that changes made on the client won’t replicate, the server will see the text as something else because of Filtering enabled. You need to pass that information to the server