'How do I anchor a part in Roblox Studio without anchoring it?
I made a small test boat for my tower defense game and I need the turret to rotate but not the rest of the boat and I can't anchor the boat because of network ownership. If I try welding or adding joints to the boat (non turret part) it rotates the whole boat. Without welds the boat teleports to where it was before I put it in replicated storage (but not the turret). I used a humanoid to rotate the turret to make it a bit easier to setup. So how do I make sure the boat base is placed in the chosen spot and only the turret rotates? The Boat Base spawns in one spot but not the turret. The joints and everything in the whole boat tower.
local allowedToSpawn = tower.CheckSpawn(player, name)
if allowedToSpawn then
local newTower = ReplicatedStorage.Towers[name]:Clone()
newTower.HumanoidRootPart.CFrame = cframe
newTower.Parent = workspace.Towers
newTower.HumanoidRootPart:SetNetworkOwner(nil)
local bodyGyro = Instance.new("BodyGyro")
bodyGyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
bodyGyro.D = 0
bodyGyro.CFrame = newTower.HumanoidRootPart.CFrame
bodyGyro.Parent = newTower.HumanoidRootPart
for i, object in ipairs(newTower:GetDescendants()) do
if object:IsA("BasePart") then
PhysicsService:SetPartCollisionGroup(object, "Towers")
end
end
Solution 1:[1]
Set the position of the turret to the boats position and give it a offset
local boat = the boat
local turret = the turret
while wait(0.01) do
turret.Position = boat.Position + Vector3.new(1,1,1) --the offset
end
If you didnt mean it like this then I have no idea what you want
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Whoman |