Help With Remote Events

Hello developers!

I’m more than likely just forgetting, but I need to make it send the text from the player’s gui to the server script. How can I do this?

Code:
Note: The text is in a text box thats in the same screen gui.

-- Screen Gui Button
local debounce = false

script.Parent.MouseButton1Click:Connect(function()
	if debounce == false then
		debounce = true
		game.ReplicatedStorage.myHotel.GiveCard:FireServer()
		wait(2)
		debounce = false
	end
end)

-- Server Script
game.ReplicatedStorage.myHotel.GiveCard.OnServerEvent:Connect(function(Player, Text)
	if game.ServerStorage.myHotel.CurrentRooms.Value >= game.ServerStorage.myHotel.MaxRooms.Value then
		print("Cannot give room! Hotel is at max capacity.")
	else
		local card = game.ServerStorage.myHotel.Card:Clone()
		card.Name = game.ServerStorage.myHotel.CurrentRooms.Value +1
		card.Parent = Player.Backpack
		game.ServerStorage.myHotel.CurrentRooms.Value = game.ServerStorage.myHotel.CurrentRooms.Value +1
	end
end)

You forgot to send text when firing remote event

My brain probably isn’t working today. What should I send? Thanks.

It should look like this:

game.ReplicatedStorage.myHotel.GiveCard:FireServer(Textbox.Text)

And don’t forget to define Textbox

Anything to change in the server script?

No, but I don’t see anything related to Text argument in OnServerEvent did you not post full code or are you going to use it later?

I was trying something else, I must’ve forgotten to remove it.

I think I’m just being stupid but I’m not sure still.

Code:

-- Gui Script (Local)
local debounce = false
local TextBox = script.Parent.Parent.Parent.User.TextBox

script.Parent.MouseButton1Click:Connect(function()
	if debounce == false then
		debounce = true
		game.ReplicatedStorage.myHotel.GiveCard:FireServer(TextBox.Text)
		wait(2)
		debounce = false
	end
end)

-- Server Script (Script)
game.ReplicatedStorage.myHotel.GiveCard.OnServerEvent:Connect(function()
	if game.ServerStorage.myHotel.CurrentRooms.Value >= game.ServerStorage.myHotel.MaxRooms.Value then
		print("Cannot give room! Hotel is at max capacity.")
	else
		local card = game.ServerStorage.myHotel.Card:Clone()
		card.Name = game.ServerStorage.myHotel.CurrentRooms.Value +1
		card.Parent = 
		game.ServerStorage.myHotel.CurrentRooms.Value = game.ServerStorage.myHotel.CurrentRooms.Value +1
	end
end)

I’m just stupid and not sure what to add here.

To

game.ReplicatedStorage.myHotel.GiveCard.OnServerEvent:Connect(function(Player, Text)

1 Like

anything needed to be changed in the local script?

I did this and it only gives it to me.

No nothing needs to be changed. Are you getting an error?

Nope. Want to be invited to team create to look?

I believe I got a fix. For “card.Parent =” should I put player.Backpack or something else?

Yes. That sounds like a better solution

I tried player.Backpack and no matter what, it only adds to mine.

Oh you want it to add to all players, oh. Here is a script to add to the server:

for _, Player in pairs(game:GetService("Players"):GetPlayers()) do
   card.Parent = Player.Backpack
end

Try doing that.

Still only gives it to me some reason.

Try this

-- Screen Gui Button
local debounce = false

script.Parent.MouseButton1Click:Connect(function(Player)
	if debounce == false then
		debounce = true
		local text = script.parent.text 
game.ReplicatedStorage.myHotel.GiveCard:FireServer(Player,  text)
		wait(2)
		debounce = false
	end
end)

Just line the codes properly , I only use mobile lol

Is myHotel a folder and GiveCard is a remote event?

Is this an IntValue?

Where will you want this to bring? It’s blank