For some reason my output is erroring: ReplicatedStorage.Modules.StormModule:11: invalid argument #1 to ‘new’ (Vector3 expected, got number) and I want to set the CFrame or Position to somewhere random, which is already set using the parameter pos (set in diff script) Thanks for helping!
function StormModule.Spawn(pos)
local Supercell = ReplicatedStorage.Replicables.Supercell
local SupercellClone = Supercell:Clone()
SupercellClone.Parent = workspace.Storms
SupercellClone.Name = "Supercell"
Supercell.CFrame = CFrame.new(pos)
end
Make sure you post all relevant code. Clicking on the error will lead you to line 11, which is giving an invalid argument for the new constructor, which I’m assuming pos is actually a number, not a Vector3 based off the error message.
line 11 is Supercell.CFrame = CFrame.new(pos) supercell is a model, I may have to use primary part again but it would interfere with another function that makes it.
while true do
RandomDirectionSpeed = math.random(-100, 300)
x = math.random(-200, 200)
y = math.random(27.549,27.549)
z = math.random(-200, 200)
StormModule.Spawn(x,y,z)
StormModule.MoveAndDissipate(RandomDirectionSpeed, 10, 3) --// WindDirection, WindSpeed, Time
wait(3)
end
``` this is the script for intializing the module
CFrame is not a valid member of Model “ReplicatedStorage.Replicables.Supercell” is my new error, the code line says: Supercell.CFrame = Vector3.new(x,y,z)
Remember, documentation is your best friend. Models do not have a CFrame property. If you want to manipulate it’s position without relying on a PrimaryPart (or any BasePart for that matter), refer to the previous post where I showed you about PivotTo and GetPivot.
-- use SupercellClone, not Supercell
SupercellClone:PivotTo(CFrame.new(x, y, z))
thank you so much! I hadnt worked with positioning models and thats a big learning experience for me, I appreciate your help on both parts. Have a good night or day idk its midnight for me and im slowly going insane