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

Welding bug on Roblox? (This is either a bug or it's my script I am not sure)

Asked by 7 years ago
Edited 7 years ago

Hey guys, So today I was attempting to make a Part Weld above my Character's head and when I hold the key 'Q' on my keyboard down it is supposed to(and it does) keep multiplying the number that the function returns and keeps multiplying the C0 of the Weld.

The problem is stated after the script!

This is what I've gotten done:

local player = game.Players.LocalPlayer;
local uis = game:GetService("UserInputService");
local deb = false;
local num = 0;

function number()
    while deb == true do
        wait();
        num = num + 0.01;
        return num;
    end
end

function fun(inputObject, gp)
    if inputObject.KeyCode == Enum.KeyCode.Q and not gp then
        pcall(function()
        deb = true;
        local part = Instance.new("Part", workspace);
        local weld = Instance.new("Weld", part);
        local char = player.Character;
       local torso = char:WaitForChild("Torso");
        part.Name = player.userId;
        part.Shape = "Ball";
        part.CanCollide = false;
        part.Anchored = false;
        part.TopSurface = "Smooth";
        part.BottomSurface = "Smooth";
        part.BrickColor = BrickColor:random();
        part.Reflectance = math.random();
        part.Transparency = math.random();
        part.CFrame = torso.CFrame;
        weld.Part0 = part;
        weld.Part1 = torso;
        weld.C0 = CFrame.new(0, -6, 0);
        while deb == true do
            wait();
            local numb = number();
            print(numb);
            weld.C0 = weld.C0 * CFrame.fromEulerAnglesXYZ(0, numb, 0);
        end
        end)
    end
end

function ended(inputObject, gp)
    if inputObject.KeyCode == Enum.KeyCode.Q and not gp then
        deb = false;
        local part = workspace:findFirstChild(player.userId);
        part:Destroy();
        num = 0;
    end
end

uis.InputEnded:connect(ended);
uis.InputBegan:connect(fun);

The above script works however, there's one little problem. Sometimes when I am walking it makes me spin and changes my Torso's position to be under the Baseplate and then I am the one spinning around rather then the other Part. There is only one error that I had and I think I understand why it is but, if there's a method that any of you guys have to fix it that would be appreciated.

19:47:33.113 - Players.KingLoneCat.PlayerGui.LocalScript:39: bad argument #2 to 'fromEulerAnglesXYZ' (number expected, got nil) 19:47:33.114 - Stack Begin 19:47:33.115 - Script 'Players.KingLoneCat.PlayerGui.LocalScript', Line 39 19:47:33.116 - Stack End

So I was wondering if it was a Roblox bug or if it was simply something I've done in the script or perhaps something I need to add to the script.

Thank you and any help is appreciated.

Answer this question