Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Part not rotating? [Unsolved]

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

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

2 comments

1

In the future, just edit your code instead of posting an answer.

1

I mean, edit your post.

This discussion is preserved as it was. New answers, comments, and votes are closed.