Haha I see this often, people calling the function when they were supposed to pass it in! Don't worry I only know this because I made the same mistake before...
The Confusion
Functions can be passed in as arguments into other functions along with values (sorry, the way I worded it is more confusing than what it actually is), a cheap example:
local function myFunc(f, x)
f(x)
end
local function f(x)
print("Function (f) was called with argument (" .. x .. ")!")
end
f(5)
myFunc(f, 5)
"Hey, that seems pretty useless."
Sure, in this scenario it looks and probably is very useless.
An easy example would be events, which you are already using so lets go with it.
Snippet of your code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local donateEvent = Instance.new("RemoteEvent", ReplicatedStorage)
donateEvent.Name = "DonateEvent"
function checkDonation(player, donationUser, donationAmount)
print(donationUser)
game.Workspace.DonationUser.Value = donationUser
game.Workspace.DonationUser.DonationAmount.Value = donationAmount
end
donateEvent.OnServerEvent:Connect( checkDonation() )
Here to Connect(...) the OnServerEvent event a function is needed, you might have thought you passed in a function but you actually called the function and passed in whatever it returned which was nil.
local function f(x)
return x ^ 2 + 2 * x + 1
end
local a = f(5)
local b = f
Look at the difference when you call a function with parentheses and when you don't? Well now you know.
So the event never fired the function, but it was instead called with no arguments, the same thing as passing in nil for every argument. Now you know what's causing the problem, and now for the part everyone was waiting for...
Solution
TL;DR Just remove the parentheses next to checkDonation below, ¯\(insert japanese word here)/¯.
There's a good chance I made a mistake or have it all completely wrong, just reply with a comment so I can figure out the real problem.
10 comments
It was supposed to be a shrug and I had to use double backslash \ to escape lol
You mean like this? donateEvent.OnServerEvent:Connect(checkDonation)
Precisely.
It still returned NIL, with the error "bad argument #3 to Value (string expected, got nil)"
Try printing donation.Name.Text and donation.Amount.Text on the client
They return: nil and Amount. Strange, donation.Name.Text does exist and does have a value.
Could it be that it is interfering with the property Name?
Yep that was the issue ^
Good job lol
donation:FindFirstChild("Name") should find the child instead of the property