I am trying to make a script that adds a tool to a player’s inventory when used.
I used print to print who activated the script, and it kept returning “nil”, even when a player presses it. Also in the “ProxPrompt.Triggered:Connect(harvest(player))” line, the player variable is underlined in red and said to be an “unknown” global when hovering my cursor over it.
I have searched for help on the forum: I tried replacing player with uppercase Player, Plr, plr… and none seems to work.
here’s the script:
local ProximityPromptService = game:GetService("ProximityPromptService")
local fruit = script.Parent.Parent
local ProxPrompt = script.Parent
local function harvest(player)
script.Parent.Parent.Transparency = 1
script.Parent.Parent.CanCollide = false
script.Parent.Enabled = false
print(player)
wait(10)
script.Parent.Parent.Transparency = 0
script.Parent.Parent.CanCollide = true
script.Parent.Enabled = true
end
ProxPrompt.Triggered:Connect(harvest(player))