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 » Scripters
Home Search
 

Re: Raycasting Problem

Previous Thread :: Next Thread 
redmiint8 is online. redmiint8
Joined: 31 Dec 2010
Total Posts: 3681
28 Feb 2017 04:01 PM
I keep getting the following error at line 9.

17:02:52.553 - Players.Player1.Backpack.M16.Server:9: bad argument #1 to '?' (Vector3 expected, got Object)
17:02:52.553 - Stack Begin
17:02:52.554 - Script 'Players.Player1.Backpack.M16.Server', Line 9
17:02:52.554 - Stack End

Here's the scripts

[Server]

script.Parent.CreateRay.OnServerEvent:connect(function(plr, p)

local tool = script.Parent
local handle = tool.Handle
local character = script.Parent.Parent.Parent

script.Parent.Part.Flash.Script.Disabled = false

local ray = Ray.new(handle.CFrame.p,(p - handle.CFrame.p).unit * 300)
local part, position = workspace:FindPartOnRay(ray, character, false, true)

local beam = Instance.new("Part", workspace)
beam.BrickColor = BrickColor.new("New yeller")
beam.FormFactor = "Custom"
beam.Material = "Neon"
beam.Transparency = 1
beam.Anchored = true
beam.Locked = true
beam.CanCollide = false

local distance = (tool.Handle.CFrame.p - position).magnitude
beam.Size = Vector3.new(0.3, 0.3, distance)
beam.CFrame = CFrame.new(tool.Handle.CFrame.p, position) * CFrame.new(0, 0, -distance / 2)

game:GetService("Debris"):AddItem(beam, 0.1)

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(20)
end
end
tool.Handle.Fire:Play()

end)

[Client in case if needed]

local plr = game.Players.LocalPlayer

repeat wait() until plr.Character

local char = plr.Character
local Humanoid = char.Humanoid
local mouse = plr:GetMouse()
local tool = script.Parent
MouseButton = false

function fire()
script.Parent.CreateRay:FireServer(plr, mouse.hit.p)
wait(0.05)
end

enabled = true

function onActivated()
if tool.Parent == char then

if not enabled then
return
end
enabled = false
fire()

enabled = true
if MouseButton then
onActivated()
script.Parent.Part.Flash.Script.Disabled = true
script.Parent.Part.Flash.Fire1.Visible = false
script.Parent.Part.Flash.Fire2.Visible = false
script.Parent.Part.Flash.Fire3.Visible = false
end
end
end

script.Parent.Part.Flash.Fire1.Visible = false
script.Parent.Part.Flash.Fire2.Visible = false
script.Parent.Part.Flash.Fire3.Visible = false


mouse.Button1Down:connect(function() MouseButton = true onActivated() end) mouse.Button1Up:connect(function() MouseButton = false end)
Report Abuse
redmiint8 is online. redmiint8
Joined: 31 Dec 2010
Total Posts: 3681
28 Feb 2017 05:04 PM
AAAAAAAAAAAAAAAA
Report Abuse
ShadyBlue is not online. ShadyBlue
Joined: 10 Apr 2013
Total Posts: 2939
28 Feb 2017 05:09 PM
I don't think you need to use remoteevents or functions to create a ray casting gun.

You can make the script in the gun a localscript and keep the whole thing in there. I think the position the mouse clicked isn't passing correctly. If you combine that into one script I'm pretty sure it will work just fine

Om
Report Abuse
hasang1 is not online. hasang1
Joined: 09 Nov 2012
Total Posts: 903
28 Feb 2017 05:13 PM
@Shady
You seem to have no idea on how triggered a FE user would get if they saw your reply.



ROBLOX tagged my signature about how to avoid getting your posts tagged. Handy to know.
Report Abuse
ShadyBlue is not online. ShadyBlue
Joined: 10 Apr 2013
Total Posts: 2939
28 Feb 2017 05:19 PM
? I use FE. I've made plenty of weapons using a singular script and only referring to remote functions or events when damaging and creating the part. All I'm saying is he doesn't have to use a remote event to fire the ray itself

Om
Report Abuse
redmiint8 is online. redmiint8
Joined: 31 Dec 2010
Total Posts: 3681
28 Feb 2017 06:21 PM
ill try something like that
ill tell you how it goes
@ShadyBlue
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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