Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how to stop parts from spinning and rotating while theyre floating with bodyposition?

Asked by 4 years ago

I am working on custom water for my classic roblox type game and it uses body position to float objects which works 100% of the time but they continue to float and rotate and spin i've tried bodygyro but i dont know how to use it. how would I have a part touch the water, then get a body gyro equal to its original orientation? also, theyre all 2048 by 55 by 2048 parts and rely on the player to build something and have it touch the water. its a script in replicatedstorage that is duplicated into every "water part"

local sealevel1 = script.Parent.Position
local sealevel2 = script.Parent.Position.Y
test = false

script.Parent.Touched:Connect(function(part)
if part.Name == "HumanoidRootPart" 
then    local bodyposition = Instance.new("BodyPosition",part)-- second arg is parent
        bodyposition.MaxForce = Vector3.new(0,math.huge,0) -- no other directions matter
        bodyposition.Name = "BP"-- \/ no other directions are important 
        bodyposition.Position = Vector3.new(0,sealevel2 + (script.Parent.Size.Y / 2),0) -- /2 so its not at the center but at the top
end
end)

script.Parent.Touched:Connect(function(part)
if part.Parent.Name == "Floatable_Parts" or test == true 
then    local bodyposition = Instance.new("BodyPosition",part)-- second arg is parent
        bodyposition.Name = "BP" -- BP so i could add more checks in the future
        bodyposition.MaxForce = Vector3.new(0,math.huge,0)
        bodyposition.Position = Vector3.new(0,sealevel2 + (script.Parent.Size.Y / 2) + 0.2,0) -- higher than water so player's built boat wont let them touch it
end
end)

script.Parent.TouchEnded:Connect(function(part)
if part:FindFirstChildWhichIsA("BodyMover") then 
    part:FindFirstChildWhichIsA("BodyMover"):Destroy() -- delete body position 
    end -- first conditional statement ended
end)-- anonymous function ended

0
Wait, what is bodyposition? goodlead -62 — 4y
0
Did you try to set body gyro's max force to inf,inf,inf? imKirda 4491 — 4y

Answer this question