RemoteEvent not working properly

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)


https://gyazo.com/9679268f8866e959de1c59afcfae7da4

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.

2 Likes

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.

Good luck on your game. God bless.

2 Likes

You are using a Player parameter,

You are not using any parameters. Add “Player” to your FireServer function.

If this doesn’t seem to be the issue, add a print("Got here") inside the Remote Event code to actually see if it’s being read.

2 Likes

That isn’t required, OnServerEvent automatically has the player parameter.

4 Likes

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

2 Likes

Why you gotta copy my comment like that man :cry:

(just kidding of course)

1 Like

You didn’t really explain the cause why the server would see it as 0.

As seen in the gyazo link provided by the author of this topic, the TextBox’s default Text is ‘0’, meaning it wouldn’t change for the server.

1 Like

Thank you your solution worked. I appreciate it.

1 Like