generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: I need a little help with Raycasting...

Previous Thread :: Next Thread 
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 04:21 AM
Ok, basically, I'm using Raycasting in the weapons for one of my games, but there's a slight problem. The line that constructs the ray executes fine, as far as I can tell. However; the script just stops after that line. Not even an error. The line is below:

local AnimHit,AnimPos = game.Workspace:FindPartOnRay(Ray.new(Weapon.Handle.CFrame.p*BarrelPos,
(mouse.Hit.p - (Weapon.Handle.CFrame.p*BarrelPos)).unit*500),Tool)

I tried without .unit, changing the multiplier... but nothing works. Could someone please tell me what's wrong?

~Kierantech909
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
22 Jul 2013 04:25 AM
Remove the .p from the CFrame where e unit is.
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 04:33 AM
It still doesn't seem to execute the rest of the script...

~Kierantech909
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
22 Jul 2013 04:35 AM
More code?
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 05:06 AM
Ok, here's the entire section:


function animatebullet()
print("Before Ray: OK")
local AnimHit,AnimPos = game.Workspace:FindPartOnRay(Ray.new(Weapon.Handle.CFrame*BarrelPos,
(mouse.Hit.p - (Weapon.Handle.CFrame*BarrelPos)).unit*500),Tool)
print("After Ray: OK")
local expl = Instance.new("Explosion",Tool)
local explpos = Instance.new("Vector3Value",Tool)
local mhit = mouse.Hit
expl.Position = Vector3.new(AnimPos.X,AnimPos.Y,AnimPos.Z)
explpos.Value = Vector3.new(AnimPos.X,AnimPos.Y,AnimPos.Z)
expl.BlastRadius = HitRadius
expl.BlastPressure = 0
expl.Hit:connect(function(part,partdist)
local distfactor = partdist/HitRadius
distfactor = 1 - distfactor
hitlist[#hitlist+1] = part
hitdistlist[#hitdistlist+1] = distfactor
end)
print("After Expl: OK")
if mouse.Target.Parent:FindFirstChild("Humanoid") and game.Players:GetPlayerFromCharacter(mouse.Target.Parent) then
local splr = game.Players:GetPlayerFromCharacter(mouse.Target.Parent)
if mouse.Target.Parent:FindFirstChild("EnergyShield") and mouse.Target.Parent.EnergyShield.Stats.Humanoid.Health > 0 then
mouse.Target.Parent.EnergyShield.Stats.Humanoid:TakeDamage(ShieldDamage)
local swait = Instance.new("ObjectValue",mouse.Target.Parent)
swait.Name = "ShieldWait"
game.Debris:AddItem(swait,3)
else
if splr.TeamColor.Color ~= plr.TeamColor.Color then
if mouse.Target.Name == "Head" then
mouse.Target.Parent.Humanoid:TakeDamage(BaseDamage*1.25)
else
mouse.Target.Parent.Humanoid:TakeDamage(BaseDamage)
end
end
end
elseif mouse.Target.Parent:FindFirstChild("VehicleStats") then
mouse.Target.Parent.VehicleStats.VehicleHealth.Value = mouse.Target.Parent.VehicleStats.
VehicleHealth.Value - VehicleDamage
end
if mouse.Target.Name == "Light" then
mouse.Target.BrickColor = BrickColor.new("Medium stone grey")
local smashsound = game.Lighting.GameArchives.Sounds.GlassSmash:Clone()
smashsound.Parent = mouse.Target
smashsound:Play()
game.Debris:AddItem(smashsound,1)
if mouse.Target:FindFirstChild("PointLight") then
mouse.Target.PointLight.Enabled = false
elseif mouse.Target:FindFirstChild("SpotLight") then
mouse.Target.SpotLight.Enabled = false
end
end
wait(0.1)
end

~Kierantech909
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 05:38 AM
Please could someone else help me? This user seems to be offline...

~Kierantech909
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
22 Jul 2013 05:49 AM
"local AnimHit,AnimPos = game.Workspace:FindPartOnRay(Ray.new(Weapon.Handle.CFrame*BarrelPos,
(mouse.Hit.p - (Weapon.Handle.CFrame*BarrelPos)).unit*500),Tool)"

Is BarrelPos defined in an earlier part of the script?

~ The ATR Fishie ~
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 05:53 AM
Yes, BarrelPos is meant to be the barrel's position when used in conjunction with the Tool's Handle position.
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 07:18 AM
This is still a standing issue... help would be much appreciated.

~Kierantech909
Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
22 Jul 2013 07:22 AM
Tool is already assigned (and has proper capitalization), I assume?
Report Abuse
dabestscripterevar is not online. dabestscripterevar
Joined: 16 Jul 2013
Total Posts: 78
22 Jul 2013 07:22 AM
There are always free models when you need them
Just sayin'
Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
22 Jul 2013 07:23 AM
Leave. Now. Get out.

Get out of the one decent forum on ROBLOX. Seriously. Leave. Now. The door's that way.

Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 07:29 AM
Yes, every variable is accounted for.

~Kierantech909
Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
22 Jul 2013 07:35 AM
And you've checked to make sure the capitalization of every variable is correct? That seems to be our most common issue. Poor capitalization.
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 07:37 AM
I capitalized everything. It would've shown an error if not, right?

~Kierantech909
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 07:38 AM
Well... not EVERYTHING, per say, but you know what I mean.

~Kierantech909
Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
22 Jul 2013 07:44 AM
It would really help if this had an output >..<
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 07:52 AM
I know it stops between the Ray.new line and the line after, but aside from the prints, there's nothing.

~Kierantech909
Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
22 Jul 2013 07:57 AM
Something wrong with this, I suppose.

Weapon.Handle.CFrame*BarrelPos,
(mouse.Hit.p - (Weapon.Handle.CFrame*BarrelPos)).unit*500

You're sure everything's pointing to the right path? mouse?


Try this, maybe?

local whateverthisdoesntmatter = Ray.new(Weapon.Handle.CFrame*BarrelPos, (mouse.Hit.p - (Weapon.Handle.CFrame*BarrelPos)).unit*500
Report Abuse
darthpyro is not online. darthpyro
Joined: 18 Aug 2009
Total Posts: 3569
22 Jul 2013 08:01 AM
woops forgot a bracket on the end of whateverthisdoesntmatter
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 08:09 AM
Ok, I put that in, and it's stopping after the new Ray.new line. I put another print between it and the line that utilizes the ray, but that print didn't fire.

~Kierantech909
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 12:06 PM
Anyone else got any ideas? I'm starting to get desperate.

~Kierantech909
Report Abuse
Debranched is not online. Debranched
Joined: 18 Mar 2013
Total Posts: 266
22 Jul 2013 12:12 PM
What type of variable is BarrelPos? Vector3 or CFrame?
Report Abuse
Kierantech909 is not online. Kierantech909
Joined: 04 Jul 2009
Total Posts: 818
22 Jul 2013 12:45 PM
BarrelPos is a Vector3.

~Kierantech909
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image