I am honestly confused. When I use a local script from a player's gui, the local script fires a server event that places a thing. However, for some reason. the 'cost' variable is being asked for a vector3 in the logs, when its a number value. Placing ServerEvent Code:

game:GetService("ReplicatedStorage").LocalEvents.Placing.OnServerEvent:connect(function(tower,pos,cost,rotation)
	game:GetService("ReplicatedStorage").Stats.Cash.Value = game:GetService("ReplicatedStorage").Stats.Cash.Value - cost
		local tt = game:GetService("ReplicatedStorage").Storage.Turrets[tower][tower]:Clone()
tt = tt:Clone()
tt.Parent = workspace.Game.Turrets
tt:SetPrimaryPartCFrame(CFrame.new(pos.X,((tt.PrimaryPart.Size.Y/2)+pos.Y)+0,pos.Z)*CFrame.Angles(0,rotation.y,0))
tt.Config.Shoot.Disabled = false
tt.Config.Cost.Value = cost
end)

Player Place LocalScript (Shortened):

tower = "Gunner"
cost = 300
lastrot = math.rad(90)
game:GetService("ReplicatedStorage").LocalEvents.Placing:FireServer(tower,mouse.Hit.p,cost,lastrot)

ServerScriptService.Worker:2: bad argument #1 to '?' (Vector3 expected, got number) Does anybody know why this is occuring? Thanks!

7 comments

0

OnServerEvent has a default argument, so you need to put another argument on line 1

0

game:GetService("ReplicatedStorage").LocalEvents.Placing.OnServerEvent:connect(function(plr,tower,pos,cost,rotation)

0

^ Was going to answer something like that but you answered first. Guess I have to delete my whole answer...

0

oof

0

I don't know too much about scripting, but what is the variable 'plr' for?

0

Nevermind. I got it working.

0

Please post using a code block.