How would I do this ingame?
And not this:
I don’t understand. What is it that your trying to acheive? Please clarify
Are you having trouble with keeping the sphere up top? Then just anchor it
If I anchor it, it doesn’t move… The exact thing I want is for the top to move with the sphere, but have the orientation based on the camera.
If you weld the parts to the central moving part you shouldn’t have any issues.
Weld the top to the blue sphere, then just anchor the blue sphere.
Result:
I don’t know how this could be achieved with physics / welding alone.
Place the “hat” and the sphere in the same model and add a script to this model. Make sure the hat is itself a model, e.g.:
Set the primary part of the model to whatever part you want. It doesn’t matter.
Inside the script, copy/paste this:
local sphere = script.Parent:WaitForChild("Sphere")
local hat = script.Parent:WaitForChild("Model")
local initial_offset = hat:GetPrimaryPartCFrame().p - sphere.Position
game:GetService("RunService").Heartbeat:Connect(function()
hat:SetPrimaryPartCFrame(sphere.CFrame + initial_offset)
end)
Hopefully this works :^)
With some modifications, I tried your code.
It worked for two seconds.
Then the piece flew away
After:
Thanks for trying. Modified code:
local sphere = script.Parent:WaitForChild("Ball")
local hat = script.Parent:WaitForChild("Shooter")
local initial_offset = hat.CFrame.p - sphere.Position
game:GetService("RunService").Heartbeat:Connect(function()
hat.CFrame = sphere.CFrame + initial_offset
end)
Edit: It disappears if you are still.
When rolling
Make sure all the parts for the hat are:
- Anchored = True
- CanCollide = False
The parts are flying away because eventually the acceleration on them becomes so great, they fly away
renderstepped:Connect(function()
Black cage thing. Position = Sphere.Position + Vector3.new(0,whatever offset that makes sense, 0)
end)
make black cage thing anchored and cannot collide
As @PerilousPanther said weld it. I don’t know what sort of logic CFraming it every renderstepped is. You can edit the c0 and c1 of the weld via command bar.
if you want the model to have the same rotation as the camera but stay fixed in its position this is how you can do that
-- localscript
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local model = ...
local cFrame = model:GetPivot()
runService.Heartbeat:Connect(function(deltaTime)
model:PivotTo(camera.CFrame.Rotation + cFrame.Position)
end)