Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

What does this script mean? Its from a AlvinBlox Video - Creating a Gun

local head = game.Workspace[player.Name].Head.Cframe.lookVector

local mouse = Cframe.new(game.Workspace[player.Name].Head.Position, mouse.Hit.p).lookVector

Here is the link to the video - https://www.youtube.com/watch?time_continue=3108&v=acJu605JNQE&feature=emb_logo

From what I understand

The head variable defines the lookVector of the head.

I am confused about the second part. First IDK what the p stand for - probably position.

I not sure but I've speculated that the mouse variable gets the Cframe of the mouse which is the extension of the head lookvector. However, the video shows the player being able to shoot in third-person, not first. So if the look vector of the head defines the mouse position then why is the avatar able to shoot in any direction without turning its head?

Why is the mouse.hit.P seperated with a comma, what does the comma do, is it the parent of the previous argument? If so why is it needed?

8 comments

0

Ok just judging from your script attempt there, you know pretty much nothing about scripting. This is a problem when it comes to learning from videos because you don't know to steer clear from AlvinBlox.

0

Once you get the basics, you'll need to learn a lot more before you can even understand how to make a gun system.

0

@SteamG0D why would he steer clear from AlvinBlox?

0

@Nogalo, I cannot remember, so I may be wrong, but IIRC he never explained stuff.

0

I would recommend that you use SkeleDotLua's tutorial, cause AlvinBlox's tutorial is old and not good.

0

I read the whole WIKI basics, and some simple tutorial that I could understand, is that enough? I been at scripting for like a month.

1 answer

Well, I would not post here for scripting help if you do not know about scripting. I would recommend covering the basics before getting into CFrames as they get really difficult really quickly.

Line 1 does pretty much does what you say. It references the lookVector of the playes head (the direction they are looking pretty much), and points to it with the variable head.

Line 2 is not really clear what is for, and to me it makes no sens. We made a variable called mouse, and then we use the variable for the assignment in its decleration statements. What? This makes no sense. I would reccommend looking at https://developer.roblox.com/en-us/articles/Understanding-CFrame for some of the basics of CFrames. They are extremely valuable, but complex.

This discussion is preserved as it was. New answers, comments, and votes are closed.