How to refrence player in a bindable event

I dont really know how to reference a player in a bindable event and I need help! Thank you for your time

local repStorage = game:GetService("ReplicatedStorage")
local Banana = game.Workspace.Banana
local bananaPrompt = Banana.BananaPrompt
local bananaPurchased = repStorage.BananaPurchased

bananaPurchased.Event:Connect(function(player)
	local gold = player.leaderstats.Gold
	
	if gold.Value >= 10 then
		gold.Value = gold.Value - 10
		Banana:Clone().Parent = player.Backpack
	end
end)
3 Likes

You can run bananaPurchased:Fire(player).

1 Like

in any server script, add this:

workspace.Banana.BananaPrompt.Triggered:Connect(player)
game.ReplicatedStorage.BananaPurchased:Fire(player)
end)

I did it and it gave me a orange lines

doesnt work either and i put it in a diffrent script inside the tool

what does it say

(30charrulego)

when i made the new script and put it inside the banana → prox prompt → the new script. It shows unkown global player

and a random end)
got assuming it shouldnt be there

taggging you for a notificaiton

my bad.

workspace.Banana.BananaPrompt.Triggered:Connect(function(player)
game.ReplicatedStorage.BananaPurchased:Fire(player)
end)

forgot to add ‘function’ inside connect

got the same error


heres the image of where i put that code

Let me see replicated storage

(30char)

here it is remember this is a bindable event and my friend made another bindable event so i just highlighted the one we were focused on
image_2023-08-07_193114417

I have to ask, are you trying to communicate between the Server and the Client, or just internally on the server?

Just reference the player at the beginning of the script

local player = game.Players.LocalPlayer
local repStorage = game:GetService("ReplicatedStorage")
local Banana = game.Workspace.Banana
local bananaPrompt = Banana.BananaPrompt
local bananaPurchased = repStorage.BananaPurchased

bananaPurchased.Event:Connect(function()
	local gold = player.leaderstats.Gold
	
	if gold.Value >= 10 then
		gold.Value = gold.Value - 10
		Banana:Clone().Parent = player.Backpack
	end
end)

both servers i am not using a remote event because I have to use a proximity prompt inside a tool too buy the banana

that script is a shophandler
(30charlimitsss

try:

script.Parent.Triggered:Connect(function(player)
game:GetService("ReplicatedStorage").BananaPurchased:Fire(player)
end)

OH I FOUND THE PROBLEM

1 Like

you never received the player argument when receiving the event

bananaPurchased.Event:Connect(function(player)

where do i put that?
(3odcahrr