-
What do you want to achieve? Keep it simple and clear!
I want to get the player that clicks on a button, to give them an item. -
What is the issue? Include screenshots / videos if possible!
the issue is in a normal script
When I print player from the function it says nil
for i, item in pairs(game.Workspace.House.Shop.SurfaceGui.Frame.NormalShop:GetChildren()) do
local priceofobject
if item:FindFirstChildWhichIsA("TextButton") then
item:FindFirstChildWhichIsA("TextButton").MouseButton1Click:Connect(function(player) -- player equals nil--
local price = item:FindFirstChildWhichIsA("TextButton").Name
if money >= tonumber(price) then
if item.Name == "Food" then
local sardines = game.ReplicatedStorage["Can of sardines"]:Clone()
money -= tonumber(price)
sardines.Parent = player.Backpack
end
game.ReplicatedStorage["Money transfer"]:FireAllClients(money)
else
print("You are soo poor")
end
end)
end
end
- What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried placing the code into a local script but the tool that the player receives can only be seen by the player who has the tool.
I have also tried looking on the DevForm