No error is printed, I tried to use pcall function to, none worked, any thing to fix in script?
its something with the remoteevent then
I see man.try using
FireServer:(game.Players:GetUserIdFromNameAsync(script.Parent.TextBox.Text),script.Parent.MoneyValueBox.Text)
That’s what I did first, later I changed it to variables, to find any errors in script
Now turns out the entire script broke ;D
he wants to detect numbers so that the intvalue will not break
i have an idea, try to do the thing u did eariler then add this
if script.Parent.Textbox.Text:match("%d+$") then
–ur code
end
Yes, also after removing this line tonumber(script.Parent.MoneyValueBox.Text) ~= nil
local script worked and remote event was fired, but server side, it printed random userid again
Whats wrong with tonumber(script.Parent.MoneyValueBox.Text) ~= nil
,its a number and tonumber(text) is printing nil, its not a string why it prints nil?
maybe its something with the textbox
Its a number, and I type 1500 in it, so the server know how much to give the player from the game wallet of player
can you please show us the textbox properties, maybe somethings messing it up
ok so use this
local group={tonumber(game.Players:GetUserIdFromNameAsync(script.Parent.TextBox.Text),script.Parent.MoneyValueBox.Text}
game.ReplicatedStorage.SendMoneyEvent:FireServer(group)
then in Server script
use .OnServerEvent(plr,group)
local toplr=group[1]
print(toplr)
end)
no im asking for the textbox properties
can you screenshot it? maybe something will mess it up
This thread’s replies are getting insanely bloated. Please do some of your own testing on the solutions you’re proposing or try getting more information so you can look more closely at the problem. There’s a lot of prospective solutions being thrown around that don’t mean much. Please also try to condense posts: the DevForum isn’t a real-time chat room, you can condense small posts into one.
For OP: could you give more context as to the full scope of your environment? I made a quick repro in Studio that mocks up almost exactly what you’re working with given the information provided in the thread and I’m not receiving “random UserIds”. Perhaps you could compare your code and/or method of testing with my repro and see where the difference is, which may help you determine where the issue is? It works as intended, assuming no invalid inputs.
Transfer Repro.rbxl (35.8 KB)
There is no error handling. To use it, type a username first and then a dollar value and then hit send. Check your output or developer console to see respective prints from the client and the server as to what its receiving. The client will print what it will attempt to give the server and the server will print what it received from the client.
It’s far more useful to work with a repro and some context than doing a shot-in-the-dark roulette with a bunch of untested proposals.
dont make it selectable, i tried it and it broke my script long time ago
Yes, I had tried this many times, it prints correct userid, but this time it printed random so I posted it
The script in server prints its a string
game.ReplicatedStorage.SendMoneyEvent.OnServerEvent:Connect(function(plr,toplr,totalmoney)
print(toplr)
print(totalmoney)
local recdata = ds1:GetAsync(toplr)
local plrname = game.Players:GetNameFromUserIdAsync(toplr)
if plr.PlayerStats.Money.Value >= totalmoney -- 1st is intvalue and I kept money.value so I get the number, and second is number then
plr.PlayerStats.Money.Value -= totalmoney
wait(5)
if ds1:GetAsync(toplr) then
ds1:SetAsync(toplr,recdata + totalmoney)
elseif game.Players:FindFirstChild(plrname) then
game.Players:FindFirstChild(plrname).PlayerStats.Money.Value += totalmoney
end
end
end)
Both of them are numbers
check if its a number and then tonumber it and mayb it will work