Roblox issue, model position

I am trying to make a tycoon sort of game, and so if you have 5$ and interact with a red circle to buy a worker, a worker appears and stands where the red circle was.
Whats happening is I interact with it, and it comes up with this error "Position is not a valid member of Model “Workspace.Trooper/Corporal” The Trooper still goes to workspace though.
Heres the code:

script.Parent.Triggered:Connect(function(plr)
	if plr.Team==game.Teams.Imperial then
		if plr.leaderstats.Money.Value>=5 then
			local newWorker=game.ReplicatedStorage["Trooper/Corporal"]:Clone()
			newWorker.Parent=game.Workspace
			newWorker.Position=Vector3.new(-43.375, 0.125, -8.5)
			plr.leaderstats.Money.Value=-5
			script.Parent.Parent:Destroy()
		end
	end
end)```

Try giving the model a PrimaryPart and setting the CFrame of the PrimaryPart.

1 Like

Models do not have the .Position Property. Instead to move models use :PivotTo(CFRAME) to move models to your desired position. It will require CFrame instead of Vector3 though. You can convert your Vector3 value to a CFrame value doing this.

CFrame.new(Vector3here)
2 Likes

Id suggest using :PivotTo() considering that method is inferior according to Roblox considering :SetPrimaryPartCFrame and :GetPrimaryPartCFrame are depricated. :PivotTo() doesnt require you to set a primary part so its basically just a successor to the Primary Part method. You can still do it the way you wish though.

4 Likes

Try This:

script.Parent.Triggered:Connect(function(plr)
	if plr.Team==game.Teams.Imperial then
		if plr.leaderstats.Money.Value>=5 then
			local newWorker=game.ReplicatedStorage["Trooper/Corporal"]:Clone()
			newWorker.Parent=game.Workspace
			newWorker.Position=Vector3.new(-43.375, 0.125, -8.5)
			plr.leaderstats.Money.Value=-5
			script.Parent.Parent:Destroy()
		end
	end
end)```
1 Like

It says this: Unable to cast double to CoordinateFrame
Heres my code

	if plr.Team==game.Teams.Imperial then
		if plr.leaderstats.Money.Value>=5 then
			local newWorker=game.ReplicatedStorage["Trooper/Corporal"]:Clone()
			newWorker.Parent=game.Workspace
			newWorker:PivotTo(-43.375, 0.125, -8.5)
			plr.leaderstats.Money.Value=-5
			script.Parent.Parent:Destroy()
		end
	end
end)```
1 Like

I see your issue, you cant just put X,Y,Z values in there. Ill fix it for you, its a easy fix

newWorker:PivotTo(CFrame.new(Vector3.new(-43.375, 0.125, -8.5)))

1 Like