How to make part spin if player touches it

how would I make this part spin if a player goes on one side of it
(physics)

2 Likes

Give me a second and I got an answer for you.

.Touched event with :Lerp() and cooldown

it has something to do with constraints

here ya go.

local part = script.Parent -- your part here
local Spinning = false

part.Touched:Connect(function(otherpart)
	if otherpart.Parent:FindFirstChildWhichIsA("Humanoid") and Spinning == false then
		while true do
			wait()
			Spinning = true
			part.CFrame = part.CFrame * CFrame.Angles(0,math.abs(.25),0)
		end
	end
end)

2 Likes

Try somthing like

or maybe

1 Like

Okay Iā€™m going to try this to see if it works

2 Likes

Use task.wait instead of wait, its alot better than wait as its more precise.

duplicate the part u want to rotate, scale it to 1,1,1 and put it above the part in which dimension you want it to rotate (fe, when i want it to rotate in Y dimension, ill put it on top) then click create, hinge constraint, click on the part you just made and the part you want to rotate, make sure its in middle of both parts after this, place the hinge part slightly above rotating part and unanchor the rotating part, navigate to hinge constraint and set actuator type to motor and motormaaxtorque to huge number and MAKE sure to set angular velocity to 0, this will prevent it from rotating, then just add this script inisde the part u wanna rotate:

local debounce = false

part.Touched:Connect(function(hit)
if hit.Parent:WaitForChild("Humanoid") then
debounce = true
hingepart.HingeConstraint.AngularVelocity = (how fast u want it to spin)
   end
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.