ProximityPrompt placing food script issue

I’m trying to make whenever I trigger a proximity prompt, I can turn a food tool I have in a player’s hand go into a folder in the workspace and position itself where I want. The problem is when I do char:FindFirstChild(“Food”), nothing happens. I’ve tried to move it around, use a remote event because I want the part spawned on the client-side. I used FindFirstChildWhichIsA and then checked that tools name but it didn’t work.

I also have another script, this script(not the script below)instances the tool I’m referencing to and creates a name for it.

local part = workspace.SmackFoodPart
part.ProximityPrompt.Triggered:Connect(function(plr)
	print(plr)
	local char = plr.Character
	print(char)
	if char:FindFirstChild("Food") then
		print(char:FindFirstChild("Food"))
		game.ReplicatedStorage.Events.FoodEvent:FireClient(plr)
		print("Success")
	elseif plr.Character:FindFirstChild("Hammer") or plr.Character:FindFirstChild("Charred Hammer") then
		local hum = plr.Character.Humanoid
		local root = plr.Character.HumanoidRootPart
		local animation = Instance.new("Animation")
		animation.AnimationId = "http://www.roblox.com/asset/?id=15518396323"
		local animtrack = hum:LoadAnimation(animation)
		root.CFrame = workspace.HammerTeleport.CFrame
		hum.WalkSpeed = 0
		hum.JumpPower = 0
		game.ReplicatedStorage.Events.AnvilCamEvent:FireClient(plr)
		for i = 1,5 do
			animtrack:Play()
			task.wait(1.25)
		end
		hum.WalkSpeed = 16
		hum.JumpPower = 50
	end
end)

There is also just a print message in the local script I’m firing to.

1 Like

Could you tell if you get any errors or something like that?

1 Like

No errors in the output. The if statement never work.

1 Like

try “if char.Food then” instead of “if char:FindFirstChild(“Food”) then” I don’t think it will fix it but it is an alternative

1 Like

In the output it says food is not a valid member of workspace.Violet_sheer

“Food is not a valid member of Model “Workspace.Violet_sheer””

1 Like

do you have the object called food in your workspace and maybe you forgot to name it with capital F

1 Like

My player’s character is in the workspace and my player is holding the tool.

1 Like

so the tool is placed in starterpack right

1 Like

Maybe it’s because I’m calling my tool “Food” in another script?

1 Like

No, a player makes the tool with a script I made, It’s like making a burger.

1 Like

oh ok you know you can also put all the tools in starterpack and than you can say like if you have done this than your old tool with one layer will become 2 layers by adding a remove function to the script that removes the first tool and than you do another thing and than there will be added a third layer and it goes so on

1 Like

This is a local script of when a proximity prompt is triggered:

game.ReplicatedStorage.Events.MakeFoodEvent.OnClientEvent:Connect(function()
	local plr = game.Players.LocalPlayer
	local plate = workspace:WaitForChild("Handle")
	local num = -3
	local parts = workspace:WaitForChild("PlacingPartsFolder"):GetChildren()
	local tool = Instance.new("Tool", plr.Backpack)
	tool.GripPos = tool.GripPos + Vector3.new(0,1,0)
	tool.GripUp = tool.GripUp + Vector3.new(-100,0,0)
	tool.Name = "Food"
	plate.Parent = tool
	plate.CanCollide = false
	for i,v in pairs(parts) do
		local weld = Instance.new("WeldConstraint", plate)
		weld.Part0 = plate
		weld.Part1 = v
		v.Parent = tool
		v.Anchored = false
		v.CanCollide = false
		v.Position = v.Position + Vector3.new(0,-0.25,0)
	end
end)
1 Like

Is that regarding the food stacking or this food script. I can place food and stack it and turn it into a tool. The problem is I can’t get the tool when the player is holding it.

1 Like

create something that even triggers it like this
"
local tool = char:FindFirstChild(“Food”)
if tool then
– Your code here
end
"

2 Likes

I did that but it doesn’t work.

1 Like

local ProximityPrompt = script.Parent.ProximityPrompt

ProximityPrompt.Triggered:Connect(function(player)
local character = player.Character

if character then
    local humanoid = character:FindFirstChildOfClass("Humanoid")
    local tool = character:FindFirstChild("Food")

    print("Player:", player.Name)
    print("Humanoid:", humanoid)
    print("Tool:", tool)

    if humanoid and tool then
        -- Player has the "Food" tool
        print(player.Name .. " is holding the Food tool!")

        -- Your code here to handle the tool being held
    else
        -- Player doesn't have the "Food" tool
        print(player.Name .. " doesn't have the Food tool.")
    end
end

end)

2 Likes

you will have to do some debugging tell me if it printed anything

1 Like

Wow I guess I didn’t try that, thanks!

1 Like

oh ok np i am glad i could help lol

3 Likes

Oh never mind I put char not the tool.

1 Like