MyLyrics
|
  |
| Joined: 28 Jun 2012 |
| Total Posts: 36 |
|
|
| 29 Jun 2012 07:25 PM |
Ray = Ray.new(script.Parent.Handle.CFrame.p,(mouse.Hit.p-script.Parent.Handle.CFrame.p).unit*300)
XD, I copied that right from the wiki(I did this before I just needed a refresher), but I get an output... Is it outdated or something? The output says, "'new' is not a valid member." |
|
|
| Report Abuse |
|
|
MyLyrics
|
  |
| Joined: 28 Jun 2012 |
| Total Posts: 36 |
|
|
| 29 Jun 2012 07:26 PM |
Here's the FULL script if you wanted the whole thing:
User = nil script.Parent.Equipped:connect(function(mouse) User = script.Parent.Parent mouse.Button1Down:connect(function() Ray = Ray.new(script.Parent.Handle.CFrame.p,(mouse.Hit.p-script.Parent.Handle.CFrame.p).unit*300) Hit,Pos = game.Workspace:FindPartOnRay(Ray,User) if Hit and Hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid:TakeDamage(math.random(1,5)) end r = Instance.new("Part",User) r.Name = "Ray" r.BrickColor = BrickColor.new("Bright yellow") r.Transparency = 0.35 r.Anchored = true r.CanCollide = false r.TopSurface = 0 r.BottomSurface = 0 r.FormFactor = 3 dist = (Pos-script.Parent.Handle.CFrame.p).magnitude r.Size = Vector3.new(0.3,0.3,dist) r.CFrame = CFrame.new(Pos,script.Parent.Handle.CFrame.p)*CFrame.new(0,0,-dist/2) game.Debris:AddItem(r,0.1) end) end) |
|
|
| Report Abuse |
|
|
MyLyrics
|
  |
| Joined: 28 Jun 2012 |
| Total Posts: 36 |
|
|
| 29 Jun 2012 07:27 PM |
Here's the wikis script:
local Tool = script.Parent --Set a variable for the tool. local User --Create a nil value for the character which we can't find yet. Tool.Equipped:connect(function(mouse) --When it's equipped fire a function. User = Tool.Parent --Set the User variable to the character of the person using the tool. mouse.Button1Down:connect(function() --When the left mouse button is clicked fire a function. local Ray = Ray.new(Tool.Handle.CFrame.p,(mouse.Hit.p-Tool.Handle.CFrame.p).unit*300) --Make a the ray. local Hit,Position = game.Workspace:FindPartOnRay(Ray,User) --Check for collisions along the ray. if Hit then --If it hits something. if Hit.Parent:FindFirstChild("Humanoid") then --If the thing the ray hit has a humanoid. Hit.Parent.Humanoid:TakeDamage(30) --Do 30 damage if they don't have a forcefield. end --End the humanoid check. end --End the hit check. local RayPart = Instance.new("Part",User) --Create a part in the user. RayPart.Name = "RayPart" --Set its name. RayPart.BrickColor = BrickColor.new("Bright red") --Set its color. RayPart.Transparency = 0.5 --Set its transparency. RayPart.Anchored = true --Set whether it will fall or not. RayPart.CanCollide = false --Set whether people can walk though it or not. RayPart.TopSurface = Enum.SurfaceType.Smooth --Make it smooth on the top. RayPart.BottomSurface = Enum.SurfaceType.Smooth --Make it smooth on the bottom. RayPart.formFactor = Enum.FormFactor.Custom --Make it so it can be small. local Distance = (Position-Tool.Handle.CFrame.p).magnitude --Find the distance between the click and the gun. RayPart.Size = Vector3.new(0.2,0.2,Distance) --Set its size to the distance. RayPart.CFrame = CFrame.new(Position,Tool.Handle.CFrame.p) * CFrame.new(0,0,-Distance/2) --Move it halfway. game.Debris:AddItem(RayPart,0.1) --Add it to the debris. end) end)
|
|
|
| Report Abuse |
|
|
MyLyrics
|
  |
| Joined: 28 Jun 2012 |
| Total Posts: 36 |
|
| |
|
MyLyrics
|
  |
| Joined: 28 Jun 2012 |
| Total Posts: 36 |
|
|
| 29 Jun 2012 07:37 PM |
| ROBLOX is getting worse and worse by the day and that's the truth, XD. |
|
|
| Report Abuse |
|
|
MyLyrics
|
  |
| Joined: 28 Jun 2012 |
| Total Posts: 36 |
|
|
| 29 Jun 2012 07:47 PM |
| Wow, people on ROBLOX don't like to learn scripting now do they? |
|
|
| Report Abuse |
|
|
swmaniac
|
  |
| Joined: 28 Jun 2008 |
| Total Posts: 15773 |
|
|
| 29 Jun 2012 08:47 PM |
Ray = Ray.new(script.Parent.Handle.CFrame.p,(mouse.Hit.p-script.Parent.Handle.CFrame.p).unit*300)
Here's your issue, your variable name is the same as the actual Ray type. Since this isn't a local variable, your new definition stays valid, so when the script runs again Ray.new doesn't exist because Ray refers to 1 Ray and not the Ray type in general. |
|
|
| Report Abuse |
|
|
MyLyrics
|
  |
| Joined: 28 Jun 2012 |
| Total Posts: 36 |
|
| |
|