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

How Do I Make A Climb Tool?

Asked by
ImfaoXD 158
8 years ago

How can I fix this script and make it works? I'm trying to make climb tool using Q or E to climb, but it doesn't work. How come? Can you guys help me out?

By the way, you can also check out this link below to the model so you could have a better of understanding:

http://www.roblox.com/Climb-item?id=316924318

Below: This is a local script not a normal script.

Player = script.Parent.Parent
Player.CharacterAdded:wait(1)
Char = Player.Character
Left, Right = Char:WaitForChild("Left Arm"), Char:WaitForChild("Right Arm")

--Put in starterpack

--Controlls: Q And E

Distance = 10 --How far they can reach

Can = true

Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(Key)
    if string.lower(Key) == "q" then
        local Q = Left:FindFirstChild("Q")
        if Q then
            Q:remove()
        end
        local Pos = Mouse.Hit.p
        if (Pos - Left.Position).magnitude < Distance then
        if Can then
        Can = false
        local Body = Instance.new("BodyPosition", Left)
        Body.Name = "Q"
        Body.maxForce = Vector3.new(20000, 20000, 20000)
        Body.position = Pos
        local Part = Instance.new("Part", Char)
        Part.Transparency = 1
        Part.FormFactor = "Custom"
        Part.Size = Vector3.new(1, 1, 1)
        local Box = Instance.new("SelectionBox", Part)
        Box.Adornee = Part
        Part.CFrame = CFrame.new(Pos)
        Part.Name = "Q"
        wait(0.25)
        Can = true
        end
        end
    end
    if string.lower(Key) == "e" then
        local Pos = Mouse.Hit.p
        local E = Right:FindFirstChild("E")
        if E then
            E:remove()
        end
        if (Mouse.Hit.p - Right.Position).magnitude < Distance then
        if Can then
        Can = false
        local Body = Instance.new("BodyPosition", Right)
        Body.Name = "E"
        Body.maxForce = Vector3.new(20000, 20000, 20000)
        Body.position = Pos
        local Part = Instance.new("Part", Char)
        Part.Transparency = 1
        Part.FormFactor = "Custom"
        Part.Size = Vector3.new(1, 1, 1)
        local Box = Instance.new("SelectionBox", Part)
        Box.Adornee = Part
        Part.CFrame = CFrame.new(Pos)
        Part.Name = "E"
        wait(0.25)
        Can = true
        end
        end
    end
end)

Mouse.KeyUp:connect(function(Key)
    if string.lower(Key) == "q" then
        local Q = Left:FindFirstChild("Q")
        local Q2 = Char:FindFirstChild("Q")
        if Q then
            Q:remove()
        end
        if Q2 then
            Q2:remove()
        end
    end
    if string.lower(Key) == "e" then
        local E = Right:FindFirstChild("E")
        local E2 = Char:FindFirstChild("E")
        if E then
            E:remove()
        end
        if E2 then
            E2:remove()
        end
    end
end)

Thanks, for helping me out.

1
'Player = script.Parent.Parent' should be 'Player = script.Parent.Parent.Parent', or even better, 'Player = game.Players.LocalPlayer' LetThereBeCode 360 — 8y
0
Indeed, as said above it's pretty silly to be using script.Parent. blah blah blah when using a local script that involves the player. It is always easier, and more reliable (No link errors) to use player = game.Players.LocalPlayer (Though this only works with local scripts!) Uroxus 350 — 8y
0
The script actually go into starter pack for it to work, but I want to turn it into a tool. How can I do that? Or it is not possible? ImfaoXD 158 — 8y
0
It like a script that require a certain place for it to work. Like for example; like 2D camera. You need to put it in starter gui for it to work. So this climb script have to be in starter pack for it to work, but I want to turn it into a tool. ImfaoXD 158 — 8y

Answer this question