Sending TextBox.Text to server via RemoteEvent not working

And it literally prints nothing? Like actually nothing?

Oh ryt, I overlooked that, but its a simple fix @greendayshade just add in a player parameter and then call the function with the player variable from the .OnServerEvent

Yeah… I tried both yours and @Mystxry12 's scripts. The local script prints the text just fine so I think it’s having trouble sending the text over? Maybe I’ll try defining the path of TextBox instead of using a variable.

edit: actually nevermind I remembered what @Mystxry12 said about my path to the textbox, lol.

Is the value not printing on the server?

Yeah, client is just fine but the server is completely refusing to output anything.

Where exactly is your ServerScript in the Explorer?

ServerScriptService. Should it not be there?

this happened to me alot of time ago, you should try to save the value as a variable and then send it

Its good there, I was wondering if the script was inactive. I assume its enabled and printing right under creating the remoteEvent works?

Can you show me what your client and server script looks like right now, it seems there has been a lot of confusion in this discussion.

2 Likes

Of course. I should’ve done that a long time ago, my apologies. It could be that I created some sort of script conflict perhaps?
LOCAL SCRIPT

local TextButton3 = script.Parent
local Players = game:GetService("Players").LocalPlayer.PlayerGui
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local GetNumberService = ReplicatedStorage:WaitForChild("LotteryNumberService")
local TextBox = Players.ChatBox1.Frame.TextBox

TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	TextBox.Text = TextBox.Text:gsub('%D+', '');
	TextBox.Text = TextBox.Text:sub(1,3);
end)

script.Parent.MouseButton1Click:Connect(function()
	local playerNumber = TextBox.Text
	GetNumberService:FireServer(playerNumber)
	print(playerNumber)
end)

SERVER SCRIPT

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local numberService = ReplicatedStorage:WaitForChild("LotteryNumberService")
local LotteryCard = game:GetService("Lighting").LotteryCard -- this line is for later don't bother with it
local sendNumbertoServer = Instance.new("RemoteEvent")
sendNumbertoServer.Name = "LotteryNumberService"
sendNumbertoServer.Parent = ReplicatedStorage

local function onButtonPress(player, text)
	local playerNumber = tonumber(text)
	if typeof(playerNumber) == "number" then 
		if playerNumber >= 0 and playerNumber <= 100 then
			--sendNumbertoServer:FireServer(playerNumber) [[ -- i'm pretty sure this shouldn't be here but i'm unsure on how to make the script fire when it's not inside the local script-- ]]
			print(playerNumber)
		end
	end
end

sendNumbertoServer.OnServerEvent:Connect(function(player, text)
	print(player.Name, text)
	onButtonPress(player, text)
end)
1 Like

You are trying to look for the RemoteEvent without it being created yet?
This yields?

1 Like

Question, is LotteryNumberService in ReplicatedStorage before play testing?

Used to. I just created a RemoteEvent manually and that fixed the issue. Should I omit the Instance.new if that’s the case?

1 Like

image
Yes, it is.

Yes, if you create it manually, you dont need to create another one by script

So I don’t need to use this?

local sendNumbertoServer = Instance.new("RemoteEvent")
sendNumbertoServer.Name = "LotteryNumberService"
sendNumbertoServer.Parent = ReplicatedStorage

and instead use the numberService variable above that’s waiting for the RemoteEvent?

1 Like

Yes, if you have 2 remote events it won’t know which one to choose
so you remove this as you said:

1 Like

Oh my god. I’m actually just stupid. The line where I defined the LotteryCard made the script error and therefore didn’t even run it since I haven’t made it yet. I’m so sorry for wasting everyone’s time. Thank you everyone for your answers. Have a good day.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.