How to find out TextBox.Text in server sided scripts

Hey i’m making a DaHood cash dropping gui. And i’m wondering how can i get the textbox.Text String inside a server script since my script doesn’t work it prints nil when i’m debugging. My script:

script.Parent.MouseButton1Click:Connect(function()
	local player = script.Parent.Parent.Parent.Parent.Parent
	local Tool = player.Backpack:FindFirstChild("Wallet") or player.Character:FindFirstChild("Wallet")
	local Amount = tonumber(script.Parent.Parent.TextBox.Text)
	print(Amount)
	if Tool ~= nil then
		Tool.DropCashEvent:Fire()
	end
end)

image
So when you click “amount” i can write text but it doesn’t change the server side text of the playergui Inside the player itself.

Please reply if u know the answer

1 Like

Make a remote event and make it fire when texbox text changed ( local script )

1 Like

Local Script:

script.Parent.MouseButton1Click:Connect(function()
	local player = script.Parent.Parent.Parent.Parent.Parent
	local Tool = player.Backpack:FindFirstChild("Wallet") or player.Character:FindFirstChild("Wallet")
	local Amount = tonumber(script.Parent.Parent.TextBox.Text)
	print(Amount)
	if Tool ~= nil then
		Tool.DropCashEvent:FireServer(Amount) -- Remote Event
	end
end)

Server Script:inside the tool.

script.Parent.DropCashEvent.OnServerEvent:Connect(function(player,amount)
print(amount .. " Found")
end)
3 Likes
--LOCAL

local Player = script:FindFirstAncestorOfClass("Player")
local Character = Player.Character or Player.CharacterAdded:Wait()
local Backpack = Player:WaitForChild("Backpack")
local Button = script.Parent
local Frame = Button.Parent
local TextBox = Frame:WaitForChild("TextBox")

Button.MouseButton1Click:Connect(function()
	local Tool = Character:FindFirstChild("Wallet") or Backpack:FindFirstChild("Wallet")
	if Tool then
		local Event = Tool.DropCashEvent
		local Amount = tonumber(TextBox.Text)
		if Amount then
			Event:Fire(Amount)
		end
	end
end)
--SERVER
local Tool = script.Parent
local Event = Tool.DropCashEvent 

Event.OnServerEvent:Connect(function(Player, Amount)
	print(Amount)
end)

Just some minor improvements.

2 Likes