Hello Roblox Scripting Community,
I’m encountering an issue with a food tool in my game, and I’m seeking some help and guidance from fellow scripters. Here’s the problem I’m facing:
I initially created a food tool (a cake) for my game, which was working perfectly. The tool had animations and sounds, and it functioned as expected even when placed in StarterPack. I want to mention that the tool is tied to a gamepass, and that my game was flagged for having alcohol content without age restrictions, which was unintentional.
In response, I removed all alcohol-related tools from my game so I could still entertain a younger audience. To replace one of the gamepass items (an alcohol tool), I introduced a new tool called “Icing,” which the cake tool I mentioned previously. Before making any changes to the gamepass script, the cake tool was functioning correctly – players could hold it and click to eat it.
The issue arose when I updated the gamepass script from “BigBottle” (the name of the previous alcohol tool) to “Icing” (the name of the cake tool). After this change, the cake tool stopped working properly. Players could only hold the cake, and clicking to eat it did not work.
In the Studio Output, I received the error message: “Eat is not a valid member of Tool “Players.Vovix.Backpack.Icing” - Client - Eat Function:6.” However, “Eat” is a valid member of the Icing tool, so I’m puzzled by this error.
Here’s the gamepass script in ServerScriptService that gives players the cake:
local ServerStorage = game:GetService("ServerStorage")
local MarketplaceService = game:GetService("MarketplaceService")
local GamepassID_IcingDonation = 227840061
game.Players.PlayerAdded:Connect(function(player)
local function giveToolToPlayer()
local icingTool = ServerStorage:FindFirstChild("Icing")
if icingTool and MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamepassID_IcingDonation) then
local toolClone = icingTool:Clone()
toolClone.Parent = player.Backpack
end
end
player.CharacterAdded:Connect(giveToolToPlayer)
if player.Character then
giveToolToPlayer()
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local backpack = player.Backpack
local icingTool = backpack:FindFirstChild("Icing")
if icingTool then
icingTool:Destroy()
end
end)
And here’s the script for the cake tool itself:
local player = game:GetService("Players").LocalPlayer
local uis = game:GetService("UserInputService")
local toolName = "Icing" -- Tool name
local eatInputType = Enum.UserInputType.MouseButton1
local isfinished = true
local soundeat = script.Parent.Eat
local function playAnim(input)
local character = player.Character
if character then
local humanoid = character:FindFirstChild("Humanoid")
local tool = character:FindFirstChild(toolName)
if humanoid and tool and input.UserInputType == eatInputType and isfinished then
local animator = humanoid:FindFirstChild("Animator")
local animation = tool:FindFirstChild("EatAnimation")
local track = animator and animator:LoadAnimation(animation)
if track then
isfinished = false
track:Play()
wait(track.Length/5)
soundeat:Play()
track.Stopped:Wait()
isfinished = true
end
end
end
end
uis.InputBegan:Connect(playAnim)
I would appreciate any insights or suggestions on what might be causing this issue and how to resolve it. It could potentially be something easy and I’m just overthinking it. Thank you in advance for your assistance!