Cafe scripting problem | (Please do help)

Hello all, so right now I’m trying to script a cafe game and when I was scripting the donut I don’t know exactly what was wrong. I’m also new to scripting so I don’t know what’s causing the problem. image image https://gyazo.com/8d746ccf40bb845814a2c78d486be779 I would appreciate some help.

2 Likes

Just check if there is already one donut in the players inventory, if there is more, delete them

Alright I’ll try that but the main problem is that it’s unanchored.

Never mind… Use this:

''''
--\\Variables//--
local GotDonut = false -- we will use this to give only one donut to the player
local Donut = script.Parent -- donut

--\\Code//
Players.PlayerAdded:Connect(function(plr) -- when player is added (delete this if you don't want the player to get the donut when they join. 
RunService.Heartbeat:Connect(function()
  if not GoDonut then -- if they don't have donut...
     GotDonut = true 
    local DonutClone1 = Donut:Clone() -- clones donut
     DonutClone1.Name = "Donut" -- names it "Donut" 
     DonutClone1.Parent = plr.Backpack -- puts it in the player's backpack
     local DonutClone2 = Donut:Clone() -- clones donut
     DonutClone2.Name = "Donut" -- names it "Donut"
     DonutClone2.Parent = plr.StarterGear -- puts it in starterGear
  end
 end) 
end)

      '''

Alright, thanks. Do I add it with the script? image

Yeah just from my code, delete the donut variable, you already have it. Also delete this:

If you don’t want the player getting the donut when they join.
Also, you may have to combine both of our codes, maybe you can figure it out? If not I am happy to help you out!

I’ll try and do it. Again, thanks for taking the time out of your day to help, I really appreciate it.

1 Like

Also, you may have to make a welding script if there are more than one part in the donut.

I think that was the problem because I did the donut in Blender and there where too much vertices so I had to export them seperately.

Yeah so you may have to make a weld script. Also, did it work?

Nope, it’s still on the ground and not in my hand.

Well what is the problem at it?

The problem is that I can’t pick it up and it isn’t in my hand.

Can I see the script you have now?

Is the donut welded? (Every thing inside the tool is welded)

1 Like

For sure. image

Use your old script, it will be better.

1 Like

And make sure to unanchor EVERYTHING from the donut

1 Like

I have welded them, what I think is causing the problem is that there are the plate, the donut, and the icing.

It’s still duplicating in the floor not my hand.