getkoed2
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 1144 |
|
|
| 12 May 2013 09:59 AM |
I made a hopperbin that creates a ray from your head to where you clicked. It works, but instead of one ray, two rays are created. I have no idea why.
Here's the script (LocalScript):
local user = game.Players.LocalPlayer
script.Parent.Selected:connect(function(mouse) mouse.Icon = "rbxasset://textures\\GunCursor.png" mouse.Button1Down:connect(function() local head = user.Character:findFirstChild("Head") if head then if user.Character:findFirstChild("Laser") then return end local ray = Ray.new(head.CFrame.p, (mouse.Hit.p - head.CFrame.p).unit * 300) local hit, pos = workspace:FindPartOnRay(ray, user.Character) local dist = (pos - head.CFrame.p).magnitude local laser = Instance.new("Part", user.Character) laser.Name = "Laser" laser.Anchored = true laser.CanCollide = false laser.TopSurface = "Smooth" laser.BottomSurface = "Smooth" laser.BrickColor = BrickColor:random() laser.FormFactor = "Custom" laser.Size = Vector3.new(.2, .2, dist) laser.CFrame = CFrame.new(pos, head.CFrame.p) * CFrame.new(0, 0, -dist / 2) for i = 0, 1, .1 do laser.Transparency = i wait(.01) end laser:Destroy() end end) end)
|
|
|
| Report Abuse |
|
|
|
| 12 May 2013 10:03 AM |
Could be a glitch? I'm sorry I don't have the time to run this, but I wouldn't reply without something useful to say.
Instead of using a part with dimensions .2 by .2 by x, you could always use a lasso and lasso it to a part anchored at Mouse.hit.p from (as it looks like,) the player's head |
|
|
| Report Abuse |
|
|
getkoed2
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 1144 |
|
|
| 12 May 2013 10:07 AM |
I have never worked with lassos.
It might be a solution, but can you set a lasso's transparency? |
|
|
| Report Abuse |
|
|
|
| 12 May 2013 10:11 AM |
I think so. And it uses Color3 values so there's more variety in what colors to use.
Only difference it it cannot collide and doesn't cast a shadow etc |
|
|
| Report Abuse |
|
|
getkoed2
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 1144 |
|
|
| 12 May 2013 10:14 AM |
I found an article about lassos in the wiki:
http://wiki.roblox.com/index.php/RBX.lua.SelectionPointLasso_(Object)
They say Transparency doesn't work, and in another article (http://wiki.roblox.com/index.php/RBX.lua.SelectionPartLasso_(Object)) it says the lasso goes from the Torso to the point you clicked. |
|
|
| Report Abuse |
|
|
|
| 12 May 2013 10:19 AM |
Oh, sorry. I forgot that can can only go from a torso to the selected point. Well I guess you might be able to use a Part selection lasso and tie the adornee to your head and create a model containing a humanoid and torso at the mouse.hit.p
I mean, if you don't want to do that, you could always look at the scripty for that new lazer finger gear. |
|
|
| Report Abuse |
|
|
getkoed2
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 1144 |
|
|
| 12 May 2013 10:26 AM |
The weird thing is that this happened when I decided to not make the laser disappear after like 0.1 second, but to first make it fade away and then remove it. When I just removed it after 0.1 second, it didn't make a second ray. |
|
|
| Report Abuse |
|
|
|
| 12 May 2013 10:32 AM |
What do you mean fade away? Is the part anchored? When you set the position, the part should not be in the workspace (from my experience) |
|
|
| Report Abuse |
|
|
getkoed2
|
  |
| Joined: 11 Apr 2010 |
| Total Posts: 1144 |
|
|
| 12 May 2013 10:37 AM |
I mean that the transparency goes to 1. The bullet that should be there is anchored, yes.
But that doesn't change that there are two bullets, one of them disappearing in 0.1 second or even less, and one of them disappearing the way it should disappear (after it faded away). |
|
|
| Report Abuse |
|
|