Help with donation via SurfaceGui

Hi! I’m trying to track down a person who clicked the button in a SurfaceGui in my market stall. This is a button to donate, only now I can’t find a player somehow, I’ve tried everything and nothing wants to work.

This is the script (it’s a serverscript in the button in the surfacegui):

local promptEvent = game:GetService("ReplicatedStorage"):WaitForChild("Stall"):WaitForChild("Donate")

script.Parent.MouseButton1Click:Connect(function()
	local character = script.Parent.Parent
	local player = Players:GetPlayerFromCharacter(character)

	if not player then
		print("Geen speler gevonden")
		return
	end

	local assetId = script.Parent.Asset.Value

	promptEvent:FireClient(player, assetId)
	print("Fired voor:", player.Name)
end)
1 Like

MouseButton1Click passes the player that clicked as argument
Try that :

local promptEvent = game:GetService("ReplicatedStorage"):WaitForChild("Stall"):WaitForChild("Donate")

script.Parent.MouseButton1Click:Connect(function(player)

	local assetId = script.Parent.Asset.Value

	promptEvent:FireClient(player, assetId)
	print("Fired voor:", player.Name)
end)
1 Like

I’ve tried it, but in the output it gave me this error: FireClient: player argument must be a Player object

add a print statement on the player and lmk whAT it says

print(player)

I’ve done it and it says in the output: nil

try handling this in a local script then

1 Like

I’ve tried it, but on local nothing seems to happen, also no errors

1 Like

in a local script

local button = workspace.Part.SurfaceGui.TextButton -- CHANGE THIS TO YOUR BUTTON LOCATION

button.MouseButton1Click:Connect(function()

	local assetId = button.Asset.Value

	-- HANDLE THE PROMPTEVENT LOGIC HERE
end)

That doesn’t work for me. It is with me that you claim a stand, then you can put an assetID (dev-product) in a textbox via an edit-menu to then create a button in the surfacegui, so it is actually always a :clone() whereby the button does not exist yet, until it is created. See attachment how the button looks.

image

Once the data is sent, the “Donations” will be copied and placed in the scrolling frame with the assetID as the name.

You have to put the SurfaceGui in the StarterGui and set the adornee to the part.

2 Likes

1 Like

Thank you for this screenshot i’ll print it out and look at it every day

1 Like

:smiling_face_with_three_hearts::smiling_face_with_three_hearts::smiling_face_with_three_hearts::smiling_face_with_three_hearts::smiling_face_with_three_hearts: