FindFirstChild instance scripting issues

Greetings,

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)


image

1 Like

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.

you can, but it isn’t very effective for performance.

I don’t really know how to do that, I am trying to learn to script for some weeks now so I am new.

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)
1 Like

I have inserted my name and it doesn’t find me. (And it doesn’t even show my name there.)

Output:
Screenshot 2022-01-14 185321

You can’t find the text of a textbox through a server script. (sorry for the late reply)

1 Like

Alright, this worked, thanks a lot.