For some reason, my script that tries to move a model keeps saying that the “Position” isn’t a valid member of “[model name]”
the model.Position += Vector3.new(0,0.05,0)
Is there a way to fix this issue?
For some reason, my script that tries to move a model keeps saying that the “Position” isn’t a valid member of “[model name]”
the model.Position += Vector3.new(0,0.05,0)
Is there a way to fix this issue?
Hello, Yes I had a similar problem too, you have to set the primary part
You can use 2 solution
Manual PrimaryPart
Select the model in the Explorer.
In the Properties pane, you’ll see a property named PrimaryPart
. Click on the dropdown next to it.
You’ll see a list of all the parts within the model. Select the part you want to set as the PrimaryPart
.
Use Setting the PrimaryPart using a Script:
local model = game.Workspace.YourModelName -- Replace with the path to your model
model.PrimaryPart = model.PartName -- Replace 'PartName' with the name of the part you want to set as the PrimaryPart
Just in case start debugging If won’t work:
local model = game.Workspace.YourModelName -- Replace with the path to your model
if model.PrimaryPart then
model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame + Vector3.new(0, 0.05, 0))
else
warn("Model does not have a PrimaryPart set!")
end
local model = game.Workspace.YourModelName -- Replace with the path to your model
for _, part in ipairs(model:GetChildren()) do
if part:IsA("BasePart") then
part.CFrame = part.CFrame + Vector3.new(0, 0.05, 0)
end
end
Tried it, didn’t work out too well.
--server (ServerScriptService)--
local REP = game:GetService("ReplicatedStorage")
local RS = game:GetService("RunService")
local remote = REP.Lift
local Vehicle = game.Workspace.Mover.Vehicle
local Move
for _, part in ipairs(Vehicle:GetChildren()) do
if part:IsA("BasePart") then
part.CFrame = part.CFrame + Vector3.new(0, 0.05, 0)
end
end
remote.OnServerEvent:Connect(function(plr, state)
Move = state
end)
Okay, any error codes?
Ensure the Vehicle Exists :
local Vehicle = game.Workspace:WaitForChild("Mover"):WaitForChild("Vehicle")
Use the Remote Event
local Move = false
remote.OnServerEvent:Connect(function(plr, state)
Move = state
end)
while wait(0.1) do -- This will loop every 0.1 seconds
if Move then
for _, part in ipairs(Vehicle:GetChildren()) do
if part:IsA("BasePart") then
part.CFrame = part.CFrame + Vector3.new(0, 0.05, 0)
end
end
end
end
Client Side :
local remote = game.ReplicatedStorage.Lift
-- Example: To start moving the vehicle
remote:FireServer(true)
-- Example: To stop moving the vehicle
remote:FireServer(false)
Make sure that the part has a primarypart manually and If none of those worked let’s start debugging
I’ll support you with the client side and the image of the model itself.
--client (StarterPlayerScripts)--
local REP = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local remote = REP.Lift
UIS.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.E then
remote:FireServer(true)
end
end)
UIS.InputEnded:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.E then
remote:FireServer(false)
end
end)
Nothing shows up on the output either. (the movement is done via keybind by the way)
Can’t you just move it’s pivot? It’s like CFrame on models
Vehicle:SetPivot(Vehicle:GetPivot() * CFrame.new(Vector3.new(0, 0.05, 0)))
Just use SetPivot() and give it a CFrame instead of a Vector3
SetPrimaryPartCFrame is deprecated.
Model:PivotTo(targetCFrame)
is the easiest way to move models. For consistency it would be best to have a primarypart set too, as the pivot is otherwise calculated as the centre of the group of parts (which could change).