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

How to efficiently make a non-tool AND non-hopperbin weapon?

Asked by 8 years ago
Edited 8 years ago

``I've searched the question I've asked, but the answer was pretty much to weld the weapon to the player's right hand and use hopperbins.

**

Problems:**

  1. I'm trying to make a weapon without using tools, and I feel like I can do it in a much better way.
    1. Should I copy the weapon and place it into the Character, or should I just put the weapon into the Character?
    2. Are there any other methods I should be using in order to have a more efficient script?
    3. Should I be doing anything else differently in order to have a more efficient script? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. Is there an easier way to weld? (If you have an answer for this, please post.) I use functions to where it just welds it into its original position, but sometimes the function does not do its job.

Code errors: The weapon doesn't weld into its original place.

If this helps, I want it to be like the weapons you see in the ROBLOX game, Shard Online.

(I am using r15 in this script, but it would help me if you could tell me how to turn off r15.)

Code Info: This is a LocalScript located in the StarterPack. There are two unions inside of the LocalScript. The two unions are called Blade and Handle.

Code so far:


local UserInput = game:GetService("UserInputService")
local Player = game:GetService("Players").LocalPlayer

local Character
local RightHand

local Enabled = true
local Equipped = false


--Equip Function--
    local function Equipped(key, GPE)
        if not Enabled then return end
        Enabled = false

        if key.KeyCode == Enum.KeyCode.Q and not GPE then
            if not Equipped then

                for _,v in pairs(script:GetChildren()) do
                    if v.ClassName == "UnionOperation" or v.ClassName == "Part" or v.ClassName == "WedgePart" then
                        local new = v:Clone()
                        new.Parent = Character
                    end
                end
                local Handle = Character:FindFirstChild("Handle")
                local Blade = Character:FindFirstChild("Blade")

                local weld = Instance.new("ManualWeld", Handle)
                weld.Part0, weld.Part1 = Handle, RightHand
                weld.C0 = Handle.CFrame:toObjectSpace(RightHand.CFrame)

                local weld = Instance.new("ManualWeld", Handle)
                weld.Part0, weld.Part1 = Handle, Blade
                weld.C0 = Handle.CFrame:toObjectSpace(Blade.CFrame)             

                Equipped = true     

            elseif Equipped then 

                for _,v in pairs(Character:GetChildren()) do
                    if v.ClassName == "UnionOperation" or v.ClassName == "Part" or v.ClassName == "WedgePart" then
                        if v.Name == "Blade" or v.Name == "Handle" then
                            v:Destroy()
                        end
                    end
                end             

                Equipped = false
            end
        end
        Enabled = true
    end
------------------

UserInput.InputBegan:connect(Equipped)

--Gets Character--
    local function GetCharacter(char)
        Character = char
        RightHand = Character:WaitForChild("RightHand")
    end

    if Player.Character then
        GetCharacter(Player.Character)
    end

    Player.CharacterAdded:connect(GetCharacter)
------------------

Basically, I want to know the best methods to make an efficient non-tool and non-hopperbin weapon. I also want to know if there is an easier way to weld.

0
Please fix your code block. alphawolvess 1784 — 8y
0
Oh, sorry. How do I do it though? iiTylerSoul 56 — 8y
0
I am new to Scripting Helpers, so I do not know how to make code blocks and stuff. iiTylerSoul 56 — 8y
0
Also, what's wrong with using a Tool? Hopperbins are currently deprecated because Tools can work w/o a handle. Are you actually trying to just have a weapon that doesn't use ROBLOX backpack? alphawolvess 1784 — 8y
View all comments (9 more)
0
Never mind. I figured it out. iiTylerSoul 56 — 8y
0
@alphawolvess, yes I want the weapon to not use ROBLOX backpack. I don't want the weapon to appear in the player's backpack. I want the tool to be equipped by using a key iiTylerSoul 56 — 8y
0
You can disable parts of the gamei,http://wiki.roblox.com/index.php?title=Disabling_parts_of_the_game_interface User#5423 17 — 8y
0
@kingdom5, thanks for the link, but the player is still able to equip the weapon by using a number. iiTylerSoul 56 — 8y
0
It seems to work ok for me? can you include a gif of what is happening and the code if possible User#5423 17 — 8y
0
Okay, but the sword still isn't fixed. You'll see some random objects on my player's hand. iiTylerSoul 56 — 8y
0
@kingdom5, actually the tool doesn't work at all when I turn off the backpack. sorry iiTylerSoul 56 — 8y
0
Sorry for not being clear guys, but i want to know how to script the weapon efficiently. I'm not wanting to know how to make the weapon. iiTylerSoul 56 — 8y
0
I am going to close this forum and accept the only answer. iiTylerSoul 56 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

A LocalScript in StarterPack or StarterGui can solve your problem very easily. You need to put your model in a storage folder like ReplicatedStorage, then weld handle part of the weapon to character's hand every time character spawns. To make it more efficiently, you can use Keyboard Input for pulling out and in your weapon. All of those scripts needs to be local in order to get mouse, get keyboard input and get player and character easily. I made a sword myself two weeks ago by using this technique. It works, but takes long time if you are going to use too much feature.

0
Thanks for your response, but I'm doing the same thing except my model is inside the script. iiTylerSoul 56 — 8y
0
I am sorry I respond late. I can privately help you on Roblox Private Message System. superalp1111 662 — 8y
Ad

Answer this question