Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Parts is moving player that it is welded to when resized?

Asked by 6 years ago

Okey Dokey So I have a thing that makes a bubble around the players mouth and everytime the blow it gets bigger. But like when its around 7 studs wide or 150 as the variable size the player gets pushed back everytime the bubble is blown. I feel like it has something to do with how when roblox resizes something it moves it out of any collisions but ive tried to fix that by when resizing it I first make its parent server storage then resize it then move it back into the character (in workspace) the resizing function is at line 49 Here is the script:

local Part = script.Bubble
local Size = .1
local Db = true
local BlowTime = 20
local Character = script.Parent
local Player = game:GetService("Players"):GetPlayerFromCharacter(Character)
local BubbleSize = Player:WaitForChild("leaderstats"):WaitForChild("BubblePower")
local SizeIncrease = .05
BubbleWeld = nil
function UpdateWeld()
    if BubbleWeld then
    BubbleWeld:Destroy()
    end
    -- oh roblox physics
    Part.Parent = nil
    Part.Size = Vector3.new(Size,Size,Size)
    Part.Anchored = false
    Part.CanCollide = false
    local Distance = Character.Head.Size.Z/2 + Size/2 + .05 -- got to account for the mesh stuff and shet
    BubbleWeld = Instance.new("Weld")
    BubbleWeld.Parent = Part
    BubbleWeld.Part0 = Character.Head
    BubbleWeld.Part1 = Part
    BubbleWeld.C1 = CFrame.new(0,0,0)
    BubbleWeld.C1 = CFrame.new(0,.27,Distance)
    Part.Parent = workspace
end

function BlowBubble(plyr)
    if plyr ==  Player then 
        if Db then
            Db = false
            Size = 0.1
            UpdateWeld()
            Part.Transparency = 0.1
            Part.Blow:Play()
            local ActualSize = .01 + BubbleSize.Value * SizeIncrease
            local Increase = ActualSize/BlowTime
            for i = 1,BlowTime do
                wait(.1)
                Size = Size + Increase
                UpdateWeld()
            end
            wait(.3)
            Part.Pop:Play()
            Part.PopParticle.Enabled = true
            UpdateWeld()
            Part.Transparency = 1
            BubbleSize.Value = BubbleSize.Value + 1
            Size = .1
            UpdateWeld()
            wait(.1)
            Part.PopParticle.Enabled = false
            Db = true
        end
    end
end
Part.Parent = workspace
Part.Transparency = 1
UpdateWeld()
Player:WaitForChild("BlowBubbleEvent").OnServerEvent:connect(BlowBubble)
local EquippedFlavor = Player:WaitForChild("Flavor")
function ApplyFlavor()
    print("Applying Flavor")
    wait(.05)
    Part.Color = EquippedFlavor.Color.Value
    Part.PopParticle.Color = ColorSequence.new(EquippedFlavor.Color.Value) -- this is sorta dumb
end
EquippedFlavor.Changed:connect(ApplyFlavor)
ApplyFlavor()
0
Make bubble CanCollide false? Change the weld before you change the size? cabbler 1942 — 6y

Answer this question