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

Okay can someone explain the problem with this Error?

Asked by 9 years ago
Player = game.Players.LocalPlayer
Char = Player.Character

Mouse = Player:GetMouse()

Cam = game.Workspace.CurrentCamera

function RemoveHats()
GetHats = Char:GetChildren()
for i = 1, #GetHats do
if (GetHats[i].ClassName == "Hat") then
GetHats[i]:Remove()
end
end
end

RemoveHats()

HeadGear = Instance.new("Model",Char)
HeadGear.Name = "SBSet"

Hat = Instance.new("Part",HeadGear)
Hat.Name = "HatP"
Hat.Size = Vector3.new(1,1,1)
HatMesh = Instance.new("SpecialMesh",Hat)
HatMesh.Name = "Mesh"
HatMesh.MeshType = "FileMesh"
HatMesh.Scale = Vector3.new(0.7,0.7,0.7)
HatMesh.TextureId = "http://www.roblox.com/asset/?id=91196344"
HatMesh.MeshId = "http://www.roblox.com/asset/?id=90820067"

HeadWeld = Instance.new("Weld",Hat)
HeadWeld.Part0 = Char.Head
HeadWeld.Part1 = Hat
HeadWeld.C1 = HeadWeld.C1*CFrame.new(0,-0.43,0.3)

Tool = Instance.new("HopperBin",Char)
Tool.Active = true
Tool.Name = "LaserBro"

Mouse.Button1Down:connect(function()
LaserGen(Hat, Mouse)
end)

function LaserGen(StartPoint,EndPoint) ---- This line always has a problem somehow.
local Ray = Ray.new(StartPoint.CFrame.p,(EndPoint.Hit.p - StartPoint.CFrame.p).unit*300) ---- This as well 
local Hit, Pos = game.Workspace:FindPartOnRay(Ray,Char)
local Hum = Hit and Hit.Parent and Hit.Parent:FindFirstChild("Humanoid")
if Hum then
Hum:TakeDamage(30)
 end
local Dis = (Pos - StartPoint.CFrame.p).magnitude
local rayPart = Instance.new("Part", StartPoint)
rayPart.Name          = "RayPart"
rayPart.BrickColor    = BrickColor.new("Bright red")
rayPart.Transparency  = 0.5
rayPart.Anchored      = true
rayPart.CanCollide    = false
rayPart.TopSurface    = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.formFactor    = Enum.FormFactor.Custom
rayPart.Size          = Vector3.new(0.2, 0.2, Dis)
rayPart.CFrame        = CFrame.new(Pos, StartPoint.CFrame.p) * CFrame.new(0, 0, -Dis/2)
game.Debris:AddItem(rayPart, 0.1)
end

The error keeps reporting at line 45 one of them being "= expect near <eof>"

1 answer

Log in to vote
0
Answered by 9 years ago

Your errors occur on these lines. Lines 41-43:

Mouse.Button1Down:connect(function() 
LaserGen(Hat, Mouse) 
end) 

Line 46:

local Ray = Ray.new(StartPoint.CFrame.p,(EndPoint.Hit.p - StartPoint.CFrame.p).unit*300)

So, this will be difficult to explain, but I will attempt to do it.

You are attempting to set the "EndPoint" parameter of the LaserGen function to the Mouse. The problem here is that the Mouse is not a 3D object, so I believe that is your problem.

Change line 42 to this:

LaserGen(Hat, Mouse.Hit.p)

That is what works in my raycasting gun, although I do not use functions with parameters rather than a simple localscript, but I hope what I attempted to solve here is your problem.

Also, it would be nice for you to include the full output error, rather than a guess.

Ad

Answer this question