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

How to make this part perfect in players hand?

Asked by 3 years ago

Hey fellow ScriptingHelpers users, Im making a Piggy style game and Im making it to hold only one item per person and this is my keycard script (All others keys are perfect with same script but with different math) and no, ffs not making those parts tools as it would break the "concept" of the game.

local key = script.Parent

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    local char = player.Character

    if char:FindFirstChild("Chave") then
        local oldKey = char:FindFirstChild("Chave")
        oldKey.Parent = workspace
        oldKey.WeldConstraint:Destroy()
        oldKey.CFrame = key.CFrame * CFrame.Angles(0,math.rad(45),0)
        oldKey.CanCollide = true
    end 

    if char:FindFirstChild("Martelo") then
        local oldKey = char:FindFirstChild("Martelo")
        oldKey.Parent = workspace
        oldKey.WeldConstraint:Destroy()
        oldKey.CFrame = key.CFrame * CFrame.Angles(0,math.rad(45),0)
        oldKey.CanCollide = true
    end 

    key.Parent = char
    key.CFrame = char.RightHand.CFrame *  CFrame.Angles(math.rad(180), math.rad(22.427), math.rad(-232.931)) --The math it uses

    local weld = Instance.new("WeldConstraint")
    weld.Parent = key
    weld.Part0 = key
    weld.Part1 = char.RightHand
    key.CanCollide = false
end)

Screenshot: http://pays.host/uploads/b0425be8-fb89-4d7b-a116-2fc30390e660/mGivtSmT.png The problem is the commented line, I would be SO much appreaciated if someone helped me, thanks!

1
Please note that "Martelo" means Hammer and "Chave" is Key, forgot to translate it before posting as my game is on another language. LyricalFrog3 45 — 3y
0
Hmmm.... marcusmitevaal -1 — 3y
0
idk try likemakin it longer or maybe have a part that you cant see so it pushes the key card marcusmitevaal -1 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

try pushing the keycard by putting a invisible part and the key card will be pushed i think i haven't tryed it cuz idk how lol.

Ad

Answer this question