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

Part not rotating? [Unsolved]

Asked by
u_g 90
10 years ago

I'm trying to make a boat script, where, when a player is seated, they can make the boat rotate left by pressing the "a" button, make it rotate right by pressing the "d" button, etc. However, the part named "body" does not seem to be rotating. Please help, here is the code:

local debounce = false script.Parent.Touched:connect(function(hit) if debounce == true then return end if debounce == false then debounce = true local h = hit.Parent:findFirstChild("Humanoid") if h == nil then debounce = false return end if h ~= nil then if h.Sit == true then control(h) end end end end)

function control(Humanoid) local turningleft = false local turningright = false local mouse = Humanoid.Parent:GetMouse() if turningleft == false or turningright == false then while true do wait(0.5) mouse.KeyDown:connect(function(key) if key == "a" then turningleft = true while true do wait(0.3) if turningleft == true then local body = script.Parent.Parent.Body local bx, by, bz = body.Rotation.x, body.Rotation.y, body.Rotation.z bz = bz + 1 body.Rotation = Vector3.new(bx, by, bz) end if turningleft == false then return end end end end) end end mouse.KeyUp:connect(function(key) if key == "a" then turningleft = false end end) end

1 answer

Log in to vote
0
Answered by
u_g 90
10 years ago

Sorry, let me post the code in a code block:

local debounce = false
script.Parent.Touched:connect(function(hit)
    if debounce == true then return end
    if debounce == false then
        debounce = true
        local h = hit.Parent:findFirstChild("Humanoid")
        if h == nil then
            debounce = false
            return end
        if h ~= nil then
            if h.Sit == true then
                control(h)
            end
        end
    end
end)

function control(Humanoid)
    local turningleft = false
    local turningright = false
    local mouse = Humanoid.Parent:GetMouse()
    if turningleft == false or turningright == false then
        while true do
            wait(0.5)
        mouse.KeyDown:connect(function(key)
        if key == "a" then
        turningleft = true
        while true do
            wait(0.3)
            if turningleft == true then
                local body = script.Parent.Parent.Body
            local bx, by, bz = body.Rotation.x, body.Rotation.y, body.Rotation.z
            bz = bz + 1
            body.Rotation = Vector3.new(bx, by, bz)
            end
            if turningleft == false then
                return end
        end
        end
    end)
    end
    end
    mouse.KeyUp:connect(function(key)
        if key == "a" then
            turningleft = false
        end
    end)
end
1
In the future, just edit your code instead of posting an answer. Perci1 4988 — 10y
1
I mean, edit your post. Perci1 4988 — 10y
Ad

Answer this question