Bubble Gum Sim Game | How to make the gum stick to player

I took this code and made it this:
plr.Character.Gum.CFrame = plr.Character.Head.CFrame:ToWorldSpace(CFrame.new(plr.Character.Gum.Size.x/2))
and got this error:
ServerScriptService.GravityIncrease:11: invalid argument #1 to ‘new’ (Vector3 expected, got number)
Sry I’m horrible with CFrame stuff XD

2 Likes

Use Vector3.New() inside of the CFrame.New() and set the values of vector with the ones that were provided.

1 Like

Yea I forgot to include the x and y component in the CFrames, so you should make it
CFrame.new(0,0,plr.Character.Gum.Size.x/2)

2 Likes

Hmmm… something’s still off. Here’s my code:
plr.Character.Gum.CFrame = plr.Character.Head.CFrame:ToWorldSpace(CFrame.new(0,0,plr.Character.Gum.Size/2))

Also, here’s the game, I just made it public if you want to try it for yourself:

1 Like

OH, hold up, forgot the X. Let me try that

2 Likes

Hmmm… Yeah something is still not right. I just published the game if you can try it out and see…

1 Like

Well do you have it so that every time you click, the CFrame is being readjusted?

2 Likes

Yes. I do. Do you need the full script?

1 Like

Yea you could paste the full script

1 Like

Yes. Give me one second. My studio just legit crashed… gotta reopen it

1 Like

Ok here you go:
Gum Handling:
game.ReplicatedStorage.IncreaseGravity.OnServerEvent:Connect(function(plr,increase)
plr.leaderstats.Bubbles.Value = plr.leaderstats.Bubbles.Value + 1

local humanoid = plr.Character:WaitForChild("Humanoid")

humanoid.JumpPower = humanoid.JumpPower + increase	

plr.Character.Gum.Size = plr.Character.Gum.Size + Vector3.new(1,1,1)
plr.Character.Gum.HeadPart.Size = plr.Character.Gum.HeadPart.Size + Vector3.new(1,1,1)

plr.Character.Gum.CFrame = plr.Character.Head.CFrame:ToWorldSpace(CFrame.new(0,0,plr.Character.Gum.Size.X/2))

end)

Part of the characterAdded event:
plr.CharacterAdded:Connect(function(char)
local clonedGum = game.ReplicatedStorage.Gum:Clone()
clonedGum.Parent = char
local weld = Instance.new(“Weld”)
weld.Part1 = char.Head
weld.Part0 = clonedGum
clonedGum.CFrame = char.Head.CFrame
weld.C0 = clonedGum.CFrame
weld.C1 = char.Head.CFrame
weld.Parent = clonedGum
clonedGum.CFrame = char.Head.CFrame:ToWorldSpace(CFrame.new(0,0,plr.Character.Gum.Size.X/2))
end)

1 Like

There is a glitch where when you click, it pushes you to the side a bit.

yes. idk what is up with that either…

I’m not sure if the gum variable refers to a model or a part. If it’s a model you have to use the SetPrimaryPartCFrame method on it…

There is no model that I’m cloning. Just a part.

On the ToWorldSpace, should the player.Character.Gum.Size.X/2 be the first number for the CFrame?

1 Like

Try making an Accessory for the gum to weld it to the player’s head.

  • Make an accessory, name it something like “BubbleGum”.
  • Put the gum part in the accessory and name it “Handle”.
  • Insert an attachment in the handle, it’s name will be the attachment in the rig of the same name that it will be welded to (for example, naming it “HairAttachment” will weld it to the attachment called “HairAttachment” in the rig.
    In this case, find an attachment in the rig that’s in front of the head. If there isn’t any, name the attachment to “HatAttachment”.
  • Parent the accessory to the rig and see how it looks.
  • If it isn’t placed right, position the accessory’s attachment differently until you get a good result.
1 Like

Ok. Trying this right now. Should I anchor the handle?

1 Like

No. This is just like welding, except it’s for the player.

Hmmm… it isn’t even showing up inside of the character… strange
plr.CharacterAdded:Connect(function(char)
local clonedGum = game.ReplicatedStorage.BubbleGum:Clone()
clonedGum.Parent = char

end)

I made it an accessory, handle, and attachment called HairAttachment. I’ll try HatAttachment