Hello! I need help on an error I havent gotten before it states what the title says above, the certain line in question is lua Storm.PrimaryPart.Position = Storm.PrimaryPart.Position + Vector3.new(dx, 0, dy) I provided the function, I want the storm to move based on the windDirection and time. The windspeed is reserved for tornadoes. The wind direction determines what angle the storm moves at. Thank you!
local StormModule = {}
function StormModule.Move(WindDirection, WindSpeed, Time)
local Storm = workspace.Storm.Supercell
local WindDirectionDegrees = math.rad(WindDirection or 45) -- Convert to radians, default to 45 degrees if WindDirection is nil
local Time = Time or 5 -- Use provided Time or default to 5
local function ActivateStorm()
-- Calculate displacement based on wind speed and time
local dx = Time * math.cos(WindDirectionDegrees)
local dy = Time * math.sin(WindDirectionDegrees)
-- Update the position of the storm object
Storm.PrimaryPart.Position = Storm.PrimaryPart.Position + Vector3.new(dx, 0, dy)
end
ActivateStorm()
end
return StormModule
Here’s the documentation on PrimaryPart. It’s essentially the anchor point for the model, the part of which all other parts of said model will pivot around if physics acts upon them. You’d probably want to set this to the largest part of the model, or a point in the center, or a part representing an axis.
Right. I don’t know exactly what your model looks like or how you want it to move, so I’d suggest experimenting with different part sizes to find which works best for you. I think a large part centered to it would likely work best though.
It doesn’t really matter. You can do either, but probably make it take up the entire thing. You can also generate it through the console:
Edit: By console I mean the lil command bar you can open up in studio, just paste it in, press enter and you’re gucci
local model = workspace.Storm.Supercell
local part = Instance.new("BasePart", model)
part.Name = "PrimaryPart"
local cf, size = model:GetBoundingBox()
part.Size = size
part.CFrame = orientation
model.PrimaryPart = part
That’s weird. You’re sure you’re setting the PrimaryPart property of the model? I’m not certain why you’d be getting the same error otherwise.
Ngl, you probably wanna use MoveTo() in this case. Your current code will only move the primary part and nothing else. If you did wanted to move everything, you would use CFrame movement, but then you would have to rig it. So just do Storm:MoveTo(Storm.PrimaryPart.Positon + Vector3.new(dx,0,dy)).
18:09:53.791 Positon is not a valid member of Part “Workspace.Storm.Supercell.PrimaryPart” - Server - StormModule:23 im sorry guys this is taking way to long but it threw out this error. What I want it to do is in another script directions may change (aka the degrees) and the storm moves in different wind directions intill its timer runs out.
Glad to hear that you got it worked out. Though as @OniiSamaUwU suggested, it would probably be best to make a new thread for that and mark this one with a Solution to make it easier for others having a similar issue to find a fix.