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)
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.
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)
--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)