for some reason, after the 2nd time the Grind button is pressed, the Molcajete loses its detachment from the player’s hand and falls to the floor. I can’t tell what is causing this to happen. Here’s the code in the button and a video of the issue occuring:
local Inventory = game.Players.LocalPlayer.PlayerGui.ScreenGUI.Inventory.Slots
local Cooldown = false
script.Parent.MouseButton1Click:Connect(function(Player)
if Cooldown == false then
Cooldown = true
local SelectedIngredient = game.ReplicatedStorage.SelectedIngredient.Value
if SelectedIngredient == "There is nothing here! Now go sit on the couch" then
--No Ingredients selected via the SelectIngredient Button
script.Parent.Text = "No Ingredient Selected!"
script.Parent.TextColor3 = Color3.new(1, 0.180392, 0.180392)
task.wait(1)
script.Parent.Text = ""
wait(.1)
script.Parent.Text = "Grind"
script.Parent.TextColor3 = Color3.new(1,1,1)
else
--There is a Selected Ingredient
local Found = false
--Checks to see if that item exists in the player's inventory
for i,v in pairs(Inventory:GetChildren()) do
if v.ItemName.Value == SelectedIngredient then
--If found, it will remove 1 of that item and begin the grinding process
script.Parent.Parent.Parent.Buttons.InventoryButton.LocalScript.Enabled = false
Found = true
v.Count.Value -= 1
script.Parent.Text = "Grinding"
script.Parent.TextColor3 = Color3.new(0.972549, 0.592157, 0.156863)
wait(1)
while true do
script.Parent.Text = script.Parent.Text.."."
wait(1)
if script.Parent.Text == "Grinding..." then
script.Parent.Text = "Done!"
script.Parent.TextColor3 = Color3.new(0, 1, 0.317647)
game.ReplicatedStorage.Tools.GetGrindingProduct:Fire(Player)
wait(1.5)
script.Parent.Parent.Parent.Buttons.InventoryButton.LocalScript.Enabled = true
break
end
end
script.Parent.Text = "Grind ["..game.ReplicatedStorage.SelectedIngredient.Value.."]"
script.Parent.TextColor3 = Color3.new(1, 1, 1)
break
end
end
if Found == false then
--Item was not found in player's inventory
--Selected Ingredient value is reset since Selected Ingredient is no longer available
game.ReplicatedStorage.SelectedIngredient.Value = "There is nothing here! Now go sit on the couch"
script.Parent.Text = "Selected Ingredient Ran Out!"
script.Parent.TextColor3 = Color3.new(1, 0.180392, 0.180392)
wait(1.5)
script.Parent.Text = ""
wait(.1)
script.Parent.Text = "Grind"
script.Parent.TextColor3 = Color3.new(1, 1,1)
end
end
Cooldown = false
end
end)
Code connected to that line game.ReplicatedStorage.Tools.GetGrindingProduct:Fire(Player)
local RS = game.ReplicatedStorage
local Products = require(workspace.Products)
RS.Tools.GetGrindingProduct.Event:Connect(function(Player)
game.Players.LocalPlayer.Character:FindFirstChild("Molcajete").Handle.Content.Item.Value = Products[RS.SelectedIngredient.Value]
end)
robloxapp-20230507-1354586.wmv (5.8 MB)