I was making a money sending system and I wanted to try it out to see if it can see the player I want to send to. I have never used FindFirstChild before so as usual for me, nothing prints out. The code and placement are attached below. Thanks.
script.Parent.MouseButton1Click:Connect(function()
local player = script.Parent.Parent.Parent.Parent.Parent
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local receiver = script.Parent.Parent.Player.Text
local amount = script.Parent.Parent.Amount.Text
if game.Players:FindFirstChild(receiver, true) then
print("Receiver is: " ..receiver)
elseif game.Players:FindFirstChild(receiver, false) then
print("Receiver " ..receiver.. " not found.")
end
end)
You can’t put server scripts in a gui. Make it a localscript, once they click on the button, send a remote event to the server and pick the remote event up in a script in ServerScriptService. If someone would click the button, it’ll happen for everyone.
there is not a parameter for bools here. It will return nil if not found and return an instance if found.
script.Parent.MouseButton1Click:Connect(function()
local player = script.Parent.Parent.Parent.Parent.Parent
local cash = player:WaitForChild("leaderstats"):WaitForChild("Cash")
local receiver = script.Parent.Parent.Player.Text
local amount = script.Parent.Parent.Amount.Text
if game.Players:FindFirstChild(receiver) then
print("Receiver is: " ..receiver)
elseif not game.Players:FindFirstChild(receiver) then
print("Receiver " ..receiver.. " not found.")
end
end)