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.
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
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.
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