I'm clearly having trouble getting this code to work the way I want, and I believe that's mostly because I don't understand it fully nor do I understand Lua enough to fix it...
This code was passed down to me from an old friend, but without teaching me what he knew of it.
The issue is that initially the tool begins held in hand as some nonthreatening object, then upon saying "[Weapon Name] Advance" it will turn into an actual weapon (with capability to kill while enhancing one's own power). I've gotten most of the "super power" aspects finished but for whatever reason, I fail to make the weapon held properly both visually AND physically. Here is the block of code that I mess with, followed by pictures of the entire scenario:
function CastSpell() wand.Parent.Humanoid.Jump = false stick.Mesh:Remove() bullet = Instance.new("SpecialMesh") bullet.MeshId = "http://www.roblox.com/asset/?id=62275708" bullet.TextureId = "http://www.roblox.com/asset/?id=62275734" bullet.Parent = stick bullet.Scale = Vector3.new(1.5, 0.9, 1.5) wand.GripPos = Vector3.new(0, -0.2, -1.9) wand.GripForward = Vector3.new(-0.4472, 0.8944, 0) wand.GripRight = Vector3.new(0.8944, 0.4472, 0) wand.GripUp = Vector3.new(0, 0, 0) --wand.Parent.Humanoid.WalkSpeed = 30 --wand.Parent.Humanoid.MaxHealth = 5000 --wand.Parent.Humanoid.Health = 5000 end
Here are the links to the two tools I have been experimenting with...
Dention: http://imgur.com/a/Y4Mxz
Drake: http://imgur.com/a/8fdqP
If someone could take the time to review and suggesting possible fixes, that would be much appreciated. I would also appreciate in said reviews if there was directional help, i.e., teaching me what the various Grip(x) mean as well as how Vector3 and respective variables apply to them.
First thing's first, you have to understand the code.
If you don't understand it, you'll never be able to:
add to it
fix bugs
improve efficiency
And you need to thoroughly understand it, as if you wrote it yourself. You really should write code yourself anyways, but if you don't, it's all the more important to know it better than the back of your hand. This includes understanding how everything works.
There's no actual error in your code, as far as syntax is concerned. Any problems likely arise in the Grip properties.
Basically, these properties determine how your tool is positioned. Normally, you just hold tools in the center of the handle. Grip properties offset that, so you can, say, hold a tool at the bottom of the handle, or rotate the handle around.
Vector3 is used for these properties because Roblox is 3D, so you have X, Y, and Z coordinates.
Oftentimes, the easiest way to find the correct coordinates for the Grip properties is to simply manually play around with them in studio.