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:**
- I'm trying to make a weapon without using tools, and I feel like I can do it in a much better way.
- Should I copy the weapon and place it into the Character, or should I just put the weapon into the Character?
- Are there any other methods I should be using in order to have a more efficient script?
- Should I be doing anything else differently in order to have a more efficient script?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- 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:
01 | local UserInput = game:GetService( "UserInputService" ) |
02 | local Player = game:GetService( "Players" ).LocalPlayer |
12 | local function Equipped(key, GPE) |
13 | if not Enabled then return end |
16 | if key.KeyCode = = Enum.KeyCode.Q and not GPE then |
19 | for _,v in pairs (script:GetChildren()) do |
20 | if v.ClassName = = "UnionOperation" or v.ClassName = = "Part" or v.ClassName = = "WedgePart" then |
22 | new.Parent = Character |
25 | local Handle = Character:FindFirstChild( "Handle" ) |
26 | local Blade = Character:FindFirstChild( "Blade" ) |
28 | local weld = Instance.new( "ManualWeld" , Handle) |
29 | weld.Part 0 , weld.Part 1 = Handle, RightHand |
30 | weld.C 0 = Handle.CFrame:toObjectSpace(RightHand.CFrame) |
32 | local weld = Instance.new( "ManualWeld" , Handle) |
33 | weld.Part 0 , weld.Part 1 = Handle, Blade |
34 | weld.C 0 = Handle.CFrame:toObjectSpace(Blade.CFrame) |
40 | for _,v in pairs (Character:GetChildren()) do |
41 | if v.ClassName = = "UnionOperation" or v.ClassName = = "Part" or v.ClassName = = "WedgePart" then |
42 | if v.Name = = "Blade" or v.Name = = "Handle" then |
55 | UserInput.InputBegan:connect(Equipped) |
58 | local function GetCharacter(char) |
60 | RightHand = Character:WaitForChild( "RightHand" ) |
63 | if Player.Character then |
64 | GetCharacter(Player.Character) |
67 | 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.