|
| 16 Jan 2017 03:10 PM |
i've made it this far without messing up, considering my terrible skills as a scripter, and me attempting to make a gun, i have a predicament, after learning raycasting, my question is. how do i make a part run along the ray
script:
Tool.Activated:connect(function() if db == true then db = false if Particles == true then PS1.Transparency = 0.2 PS11.Transparency = 0.2 PS111.Transparency = 0.2 ShotGun:Play() local ray = Ray.new(Tool.Holder.Position, (mouse.hit.p - Tool.Holder.CFrame.p).unit * 300) local part, position = workspace:FindPartOnRay(ray, Player.Character, false, true) local BulletLine = Instance.new("Part", workspace) BulletLine.Material = Enum.Material.Neon BulletLine.BrickColor = BrickColor.new("Really red") BulletLine.FormFactor = "Custom" BulletLine.Transparency = 0.25 BulletLine.Anchored = true BulletLine.Locked = true BulletLine.CanCollide = false local distance = (Tool.Holder.Position - position).magnitude BulletLine.Size = Vector3.new(0.1, 0.1, distance) BulletLine.CFrame = CFrame.new(Tool.Holder.Position, position) * CFrame.new(0, 0, -distance/2) game.Debris:AddItem(BulletLine, 0.5) if part then local humanoid = part.Parent:findFirstChild("Humanoid") if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end if humanoid then humanoid:TakeDamage(50) end end --Bullet Follows The Ray wait(0.3) ShotGun2:Play() PS1.Transparency = 1 PS11.Transparency = 1 PS111.Transparency = 1 wait(FireRate) db = true
This is siggy. he does not like people. he will bite |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2017 03:15 PM |
bump
This is siggy. he does not like people. he will bite |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2017 03:20 PM |
my bad
Tool.Activated:connect(function() if db == true then db = false if Particles == true then PS1.Transparency = 0.2 PS11.Transparency = 0.2 PS111.Transparency = 0.2 ShotGun:Play() local ray = Ray.new(Tool.Holder.Position, (mouse.hit.p - Tool.Holder.CFrame.p).unit * 300) local part, position = workspace:FindPartOnRay(ray, Player.Character, false, true) local BulletLine = Instance.new("Part", workspace) BulletLine.Material = Enum.Material.Neon BulletLine.BrickColor = BrickColor.new("Really red") BulletLine.FormFactor = "Custom" BulletLine.Transparency = 0.25 BulletLine.Anchored = true BulletLine.Locked = true BulletLine.CanCollide = false local distance = (Tool.Holder.Position - position).magnitude BulletLine.Size = Vector3.new(0.1, 0.1, distance) BulletLine.CFrame = CFrame.new(Tool.Holder.Position, position) * CFrame.new(0, 0, -distance/2) game.Debris:AddItem(BulletLine, 0.5) if part then local humanoid = part.Parent:findFirstChild("Humanoid") if not humanoid then humanoid = part.Parent.Parent:FindFirstChild("Humanoid") end if humanoid then humanoid:TakeDamage(50) end end local Bullet = game.ServerStorage.Bullet:Clone() Bullet.Parent = game.Workspace Bullet.Anchored = false Bullet.Position = BulletHolder.Position Bullet.CanCollide = false --Bullet Follows The Ray wait(0.3) ShotGun2:Play() PS1.Transparency = 1 PS11.Transparency = 1 PS111.Transparency = 1 wait(FireRate) db = true else forgot to include adding the bullet
This is siggy. he does not like people. he will bite |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2017 03:22 PM |
on the wiki, there is a page about making a laser thing with raycasting maybe it can help you with the following bullet part |
|
|
| Report Abuse |
|
|
|
| 16 Jan 2017 03:30 PM |
^ i read it up and down and didn't find anything..
This is siggy. he does not like people. he will bite |
|
|
| Report Abuse |
|
|