Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Cafe food disappears?! How do I fix?

Hello! I am currently making a cafe game but I need help with the food. I am currently scripting a cake tool and when you step on it appears as a tool. That is working perfectly fine. However, you can only get 1 cake which is a problem. When I step on it, you only get 1 cake and nothing else. So if somebody else wanted to have the cake, they can't get it. How do i fix this?

This is my code

local Tool = script.Parent

enabled = true

function onActivated() if not enabled then return end

enabled = false
Tool.GripForward = Vector3.new(0.439, 0.878, 0.189)
Tool.GripPos = Vector3.new(-0.3, 1.2, -1.3)
Tool.GripRight = Vector3.new(0.0844, 0.169, -0.982)
Tool.GripUp = Vector3.new(0.894, -0.347, 0)


Tool.Handle.EatSound:Play()

script.Parent.Bites.Value = script.Parent.Bites.Value + 1 wait(.8)

Eable() local h = Tool.Parent:FindFirstChild("Humanoid") if (h ~= nil) then if (h.MaxHealth > h.Health + 1.6) then h.Health = h.Health + 1.6 else h.Health = h.MaxHealth end end

Tool.GripForward = Vector3.new(-1, 1, -0)
Tool.GripPos = Vector3.new(0.1, -0.3, 0)
Tool.GripRight = Vector3.new(0,0, -1)
Tool.GripUp = Vector3.new(1,0,0)


enabled = true

end

function onEquipped()

end

script.Parent.Activated:connect(onActivated) script.Parent.Equipped:connect(onEquipped)

script.Parent.Handle.Touched:connect(onTouched)

function Eable() if (script.Parent.Bites.Value) > 2 then script.Parent:Remove() end end

Please help me with this issue. Thanks!

10 comments

0

PLEASE ANSWER ASAP

0

Please provide an error as we can not debug it without one.

0

There is no error, I need to see if the code is fine. Duh

0

Could you please put all your code in a code block. This is very difficult to read.

0

Only comment here if you have an answer, thanks.

0

So you’re saying the cake is a tool, but when someone touches it, they take it and no one else can get it as they have it?

0

yeah

1

What a spoiled brat. People trying to help you and you act like this. Maybe you should respect the fact someone is trying to help.

0

By the way, we don't need any more cafes on roblox.

0

It doesn't matter. I am not spoiled. Also, who said we don't. You can't stop me from making one. It's been my ambition since and now you're just gonna put me down, how selfish.

1 answer

nothing is wrong with your code, its that roblox default mechanics directly parents the tool to the player of whoever touched its handle's backpack instead of cloning it directly, a simple fix i came up with while writing this will be listed below:

STEP 1: make a folder in ServerStorage, name it "Food"

STEP 2: put the cake in (position it where it should be first)

STEP 3, insert a model anywhere into the workspace and call it anything

STEP 4, insert a script in that model, call it anything

STEP 5: in script, write this code:

while true do
	wait() -- important delay or the game will lag out crazy
	if not script.Parent:FindFirstChildOfClass("Tool") then -- if there is no tool in the model
		wait(5) -- important delay so that the player who got the cake does not get 999 cakes in one second
		local food = game.ServerStorage.Food.WHATISYOURCAKECALLED:Clone() -- get food
		food.Parent = script.Parent  -- parent the food clone
	end
end

STEP 6: in the code there is something called: WHATISYOURCAKECALLED, rename it to the name of the cake you stored earlier (CaSe SeNsAtIvE)

This discussion is preserved as it was. New answers, comments, and votes are closed.