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

how would i rotate this model as one instead of just one part being rotated?

Asked by 4 years ago
game:GetService("Players").PlayerAdded:Connect(function(player)
    local flying = Instance.new("BoolValue",player)
    flying.Name = "flying"
    flying.Value = false
end)
local event = game:GetService("ReplicatedStorage"):WaitForChild("fly_broom")
local work = game:GetService("Workspace")

event.OnServerEvent:Connect(function(player,command)
    if player.flying.Value == false then return end
    local bodyforce
    local sit
    for i,v in pairs(work:GetChildren()) do
        if v.Name:split("'")[1] == player.Name and not v:FindFirstChild("Humanoid") then
            if v.sit:FindFirstChild("BodyPosition") then
                bodyforce = v.sit.BodyPosition
                sit = v.sit
            end
        end
    end
    if command == "W" then
        bodyforce.Parent.flying.Disabled = false
    elseif command == "Ended" then
        if not bodyforce then return end
        bodyforce.Parent.flying.Disabled = true
    elseif command == "space" then
        for i,v in pairs(bodyforce.Parent.Parent:GetChildren()) do
            v.CanCollide = true
            local turned = false
        end
        local model = sit.Parent
        sit.Touched:Connect(function()
            sit.Anchored = true
            sit.Orientation = Vector3.new(0, 0, -32.83)
            --ive tried with model:SetPrimaryPartCFrame(CFrame.Angles(numbers)) but this only put my model somewhere completely else so idk how to rotate
        end)
        bodyforce:Destroy()
        player.Character.HumanoidRootPart.WeldConstraint:Destroy()
        wait(3)
        player.flying.Value = false
    end
end)
0
try using :SetPrimaryPartCFrame() but instead of setting a new CFrame, add on to the current CFrame. that should fix it moving to a whole different position. Mayk728 855 — 4y

1 answer

Log in to vote
0
Answered by
AspectW 431 Moderation Voter
4 years ago

Assign a PrimaryPart to the model (property of model) and use the :SetPrimaryPartCFrame() method.

https://developer.roblox.com/en-us/api-reference/function/Model/SetPrimaryPartCFrame

Ad

Answer this question