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: Expected Vector3, got Object

Previous Thread :: Next Thread 
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 02:55 PM
local mouse = game.Players.LocalPlayer:GetMouse()
local Tool = script.Parent
local debris = game.Debris
local remote = Tool:WaitForChild("Fire")

Tool.Activated:connect(function() -- localscript creates target area
if Tool.Enabled then
print'hi'
local location = mouse.Hit.p
local tp=Instance.new("Part", workspace)
tp.Transparency=.5
tp.Name="Effect"
tp.Anchored=true
tp.CanCollide=false
tp.Size=Vector3.new(0,0,0)
tp.BrickColor=BrickColor.new("Lime green")
tp.CFrame=CFrame.new(location)*CFrame.Angles(math.pi/2,0,0)
local me=Instance.new("SpecialMesh")
me.MeshId="http://www.roblox.com/asset/?id=3270017"
me.Scale=Vector3.new(20,20,1)
me.Parent=tp
debris:AddItem(tp,5)
remote:FireServer(location)
end
end)

SCRIPT VVV

local fire = script.Parent:WaitForChild("Fire")

local fatman = game.Lighting.Fatman

fire.OnServerEvent:connect(function(area) -- area should be Vector3 value
for i = 1, 5 do
local chloe = fatman:Clone()
local rock = script:WaitForChild("Rocket"):Clone()
rock.Parent = chloe
chloe.Position = area + Vector3.new(math.random(-10,10),100,math.random(-10,10))
chloe.Parent = workspace
end
end)

welcome to hell how may i take your order
Report Abuse
DogeKip is not online. DogeKip
Joined: 06 Mar 2011
Total Posts: 6860
19 Jul 2016 02:55 PM
Can you post the error and the line in which the error occurs so we don't have to search your entire script, thanks


[Redacted]
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 02:57 PM
line 10 of the serverscript: bad argument #1 to '?' (Vector3 expected, got Object)

line 10 is chloe.Position

welcome to hell how may i take your order
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:03 PM
guys

welcome to hell how may i take your order
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:06 PM
please

welcome to hell how may i take your order
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:28 PM
b5

welcome to hell how may i take your order
Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
19 Jul 2016 03:33 PM
is fatman a part?
Report Abuse
DogeKip is not online. DogeKip
Joined: 06 Mar 2011
Total Posts: 6860
19 Jul 2016 03:33 PM
what is area


[Redacted]
Report Abuse
DogeKip is not online. DogeKip
Joined: 06 Mar 2011
Total Posts: 6860
19 Jul 2016 03:36 PM
There's no area being created and passed to the "fire.OnServerEvent" as far as I can see


[Redacted]
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:36 PM
fatman is a part

when i print area i get my player even though i intended to get a vector3 value

in the localscript it fires a server event with the player's mouse position

welcome to hell how may i take your order
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:37 PM
@doge

clearly you don't know that variables and arguments are inherently different but let's not get into that

in a nutshell that doesn't matter

welcome to hell how may i take your order
Report Abuse
DogeKip is not online. DogeKip
Joined: 06 Mar 2011
Total Posts: 6860
19 Jul 2016 03:38 PM
Try area.Position and it might fix your problem


[Redacted]
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:39 PM
again

when i print(area) it comes up with the player

and you can't get a position of a player by doing Player.Position

welcome to hell how may i take your order
Report Abuse
DogeKip is not online. DogeKip
Joined: 06 Mar 2011
Total Posts: 6860
19 Jul 2016 03:39 PM
Arguments are the values passed to the function and replicated in the context that they were passed to

Variables are initialized and given a value in the scope they are initialized in


[Redacted]
Report Abuse
Inigo18 is not online. Inigo18
Joined: 02 Feb 2014
Total Posts: 1041
19 Jul 2016 03:39 PM
Fix area since Position expects a Vector3 valueeeee
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Jul 2016 03:39 PM
print(area)


Report Abuse
DogeKip is not online. DogeKip
Joined: 06 Mar 2011
Total Posts: 6860
19 Jul 2016 03:40 PM
The position of a model should be based on it's primary part or the center of the area the model takes up if I'm not mistaken


[Redacted]
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:40 PM
precisely

the localscript is supposed to be telling the server "location" or the position of the mouse

the server is supposed to interpret the vector3 it gets and for short it's just known as "area"

welcome to hell how may i take your order
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:41 PM
@Time

FireServer(location), get "Player1" aka my player

welcome to hell how may i take your order
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Jul 2016 03:42 PM
Oh im stupid. You forgot the plr argument.

fire.OnServerEvent:connect(function(plr,area) --plr will always be the first argument


Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:42 PM
Doge you didn't read the code at all and it's really obvious now

The localscript is telling the position of the MOUSE to the servver

welcome to hell how may i take your order
Report Abuse
DogeKip is not online. DogeKip
Joined: 06 Mar 2011
Total Posts: 6860
19 Jul 2016 03:42 PM
So why are you using more the Mouse.Hit.p, I don't understand why you're doing what you are


[Redacted]
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:43 PM
@Time

Same error again.

REVISED CODE:

LOCALSCRIPT:

Tool.Activated:connect(function()
if Tool.Enabled then
print'hi'
local location = mouse.Hit.p
remote:FireServer(game.Players.LocalPlayer, location)
local tp=Instance.new("Part", workspace)
tp.Transparency=.5
tp.Name="Effect"
tp.Anchored=true
tp.CanCollide=false
tp.Size=Vector3.new(0,0,0)
tp.BrickColor=BrickColor.new("Lime green")
tp.CFrame=CFrame.new(location)*CFrame.Angles(math.pi/2,0,0)
local me=Instance.new("SpecialMesh")
me.MeshId="http://www.roblox.com/asset/?id=3270017"
me.Scale=Vector3.new(20,20,1)
me.Parent=tp
debris:AddItem(tp,5)
end
end)

SCRIPT:

local fire = script.Parent:WaitForChild("Fire")
local Tool = script.Parent
local fatman = game.Lighting.Fatman

local creator_tag = Instance.new("ObjectValue")
creator_tag.Name = "creator"

fire.OnServerEvent:connect(function(plr, location)
print(location)
if Tool.Enabled then
Tool.Enabled = false
for i = 1, 10 do
local chloe = fatman:Clone()
local rock = script:WaitForChild("Rocket"):Clone()
local cre = creator_tag:Clone()
cre.Parent = chloe
cre.Value = plr
rock.Parent = chloe
rock.Disabled = false
chloe.Position = location + Vector3.new(math.random(-10,10),200,math.random(-10,10))
chloe.Parent = workspace
wait(0.5)
end
wait(2)
Tool.Enabled = true
end
end)

welcome to hell how may i take your order
Report Abuse
lagio2 is not online. lagio2
Joined: 11 Mar 2010
Total Posts: 4001
19 Jul 2016 03:44 PM
@doge

everything is presented clearly in the code

welcome to hell how may i take your order
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
19 Jul 2016 03:47 PM
@OP I meant plr will be the first argument only on the server in OnServerEvent

All you have to do is

--server

re.OnServerEvent:connect(function(plr,pos)
print(plr,pos)
end

--local

re:FireServer(pos)




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