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 RenderService = game:GetService("RunService")
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
function BlowBubble(plyr)
    if plyr ==  Player then 
        if Db then
            print("Doing")
            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()
                Size = Size + Increase
                UpdateWeld()
            end
            wait(.3)
            Part.Pop:Play()
            Part.PopParticle.Enabled = true
            UpdateWeld()
            Part.Transparency = 1
            BubbleSize.Value = BubbleSize.Value + 1
            wait(.1)
            Part.PopParticle.Enabled = false
            Db = true
        end
    end
end
Part.Parent = Character
Part.Transparency = 0
Player:WaitForChild("BlowBubbleEvent").OnServerEvent:connect(BlowBubble)
-- create weld
Part.Size = Vector3.new(Size,Size,Size)
local Distance = Character.Head.Size.Z/2 + Size/2 + .05
local BubbleWeld = Instance.new("Weld")
BubbleWeld.C1 = CFrame.new(0,.27,Distance)
BubbleWeld.Parent = Part
BubbleWeld.Part0 = Character.Head
BubbleWeld.Part1 = Part
function UpdateWeld()

    -- oh roblox physics
    Part.Parent = game.ServerStorage
    Part.CanCollide = false
    Part.Size = Vector3.new(Size,Size,Size)
    Part.CanCollide = false
    Part.Parent = Character
    local Distance = Character.Head.Size.Z/2 + Size/2 + .05 -- got to account for the mesh stuff and shet
    BubbleWeld:Destroy()
    BubbleWeld = Instance.new("Weld")
    BubbleWeld.Parent = Part
    BubbleWeld.Part0 = Character.Head
    BubbleWeld.Part1 = Part
    BubbleWeld.C1 = CFrame.new(0,.27,Distance)
end

Answer this question