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

Why isn't this shooting?

Asked by 9 years ago

I'm trying to script build and I have this script:

01chr = workspace.supercoolguy53
02mouse = game.Players.LocalPlayer:GetMouse()
03 
04part = Instance.new("Part",chr)
05part.CanCollide = false
06part.Anchored = true
07part.BrickColor = BrickColor.White()
08part.Transparency = .9
09part.Size = Vector3.new(7,7,7)
10mesh = Instance.new("SpecialMesh",part)
11mesh.MeshType = "Sphere"
12 
13part.Touched:connect(function(p)
14    local h = p.Parent:FindFirstChild("Humanoid")
15    if h and h.Parent.Name ~= "supercoolguy53" then
View all 36 lines...

Everything works except for I can't shoot it. When you press q you're supposed to shoot where ever you're looking, this is my first time with this 'lookVector' thing and I don;t quite understand it. I get this error new is not a valid member

1 answer

Log in to vote
2
Answered by 9 years ago
01chr = workspace.supercoolguy53
02mouse = game.Players.LocalPlayer:GetMouse()
03 
04part = Instance.new("Part",chr)
05part.CanCollide = false
06part.Anchored = true
07part.BrickColor = BrickColor.White()
08part.Transparency = .9
09part.Size = Vector3.new(7,7,7)
10mesh = Instance.new("SpecialMesh",part)
11mesh.MeshType = "Sphere"
12 
13part.Touched:connect(function(p)
14    local h = p.Parent:FindFirstChild("Humanoid")
15    if h and h.Parent.Name ~= "supercoolguy53" then
View all 37 lines...

You forgot the fact that CFrame is a global variable, and that the CFrames of bricks do not contain constructors to create more CFrames. You must use CFrame, not BasePart.CoordinateFrame.

Basically:

1local part = Instance.new('Part', workspace)
2part.CFrame = part.CFrame.new(0,5,0) --> error: new is not a valid member of part.CFrame
3part.CFrame = CFrame.new(0,5,0) --> part gets moved to 0,5,0

I hope I helped, if you have any questions, contact me.

1
It didn't shoot the way I was facing... It was shooting tho. Senor_Chung 210 — 9y
0
Well, that was a problem in your code. It should be fixed now. TerrodactyI 173 — 9y
Ad

Answer this question