Can't find Humanoid

Hello everyone, I have a problem that after the Proximity Prompts trigger the function does not find the Humanoid and the script does not work.

local ItemPricesScript = require(game.ReplicatedStorage:WaitForChild("BuyingItems"):WaitForChild("ItemPrices"))
local Promt = script.Parent.Parent.AmongusPLUSHIE.Buy
Promt.Triggered:Connect(function(Triggered)
	local ItemName = script.Parent.Name

	repeat wait() until Triggered:FindFirstChild("Humanoid")

	local plr = game.Players:GetPlayerFromCharacter(Triggered)

	if plr then 
		local OwnedItems = plr.OwnedItems 
		if OwnedItems:FindFirstChild(script.Parent.Parent.Parent.Name) then return end

		plr.PlayerGui.BuyQ.MainFrame.Visible = true
		plr.PlayerGui.BuyQ.MainFrame.Desription.Text = "Would you like to purchase the " ..ItemName.. " ???"
		plr.PlayerGui.BuyQ.MainFrame.Desription.Yes.LocalScript.ItemName.Value = ItemName


	end

	wait(1)
end)

I used to make the same script but without Proximity Prompts.

Show us the code so we can help.

local ItemPricesScript = require(game.ReplicatedStorage:WaitForChild("BuyingItems"):WaitForChild("ItemPrices"))
local Promt = script.Parent.Parent.AmongusPLUSHIE.Buy
Promt.Triggered:Connect(function(Triggered)
	local ItemName = script.Parent.Name

	repeat wait() until Triggered:FindFirstChild("Humanoid")

	local plr = game.Players:GetPlayerFromCharacter(Triggered)

	if plr then 
		local OwnedItems = plr.OwnedItems 
		if OwnedItems:FindFirstChild(script.Parent.Parent.Parent.Name) then return end

		plr.PlayerGui.BuyQ.MainFrame.Visible = true
		plr.PlayerGui.BuyQ.MainFrame.Desription.Text = "Would you like to purchase the " ..ItemName.. " ???"
		plr.PlayerGui.BuyQ.MainFrame.Desription.Yes.LocalScript.ItemName.Value = ItemName


	end

	wait(1)
end)

here

Change

repeat wait() until Triggered:FindFirstChild("Humanoid")

local plr = game.Players:GetPlayerFromCharacter(Triggered)

To

repeat wait() until Triggered.Parent:FindFirstChild("Humanoid")

local plr = game.Players:GetPlayerFromCharacter(Triggered.Parent)

image
When I triggered Proximity Prompts there was no action, and when I left the place I got this error
error - " Workspace.Podval.Shop.Amogus.AmongusPLUSHIE.Script:6: attempt to index nil with ‘FindFirstChild’ "
[image]

Check the thing I sent again, I found another error, I can’t see the image BTW.

I remembered it needs 2 parameters, one for the object and the second is for the player, you forgot that parameter.

Do this

Promt.Triggered:Connect(function(Triggered, player) 

There is a second parameter, Read my last reply, above this.

Workspace.Podval.Shop.Amogus.AmongusPLUSHIE.Script:6: attempt to index nil with 'FindFirstChild'

The error does not disappear

I did mistake I thought it was touch script lol Im sorry

There are no errors, but Proximity Prompts does not give results

Use this, will work, I remembered how they actually work now.

local ItemPricesScript = require(game.ReplicatedStorage:WaitForChild("BuyingItems"):WaitForChild("ItemPrices"))
local Promt = script.Parent.Parent.AmongusPLUSHIE.Buy

Promt.Triggered:Connect(function(plr) --returns the player object not the character. 
	local ItemName = script.Parent.Name
 
	local OwnedItems = plr.OwnedItems 
	if OwnedItems:FindFirstChild(script.Parent.Parent.Parent.Name) then return end

	plr.PlayerGui.BuyQ.MainFrame.Visible = true
	plr.PlayerGui.BuyQ.MainFrame.Desription.Text = "Would you like to purchase the " ..ItemName.. " ???"
	plr.PlayerGui.BuyQ.MainFrame.Desription.Yes.LocalScript.ItemName.Value = ItemName

	wait(1)
end)
3 Likes