Bug fix on a script

I’ve recently received a script, basically all I wanted was if you press “E” on the proximity prompt once the valve wheel spins to the right, and when you press it again it spins to the left. But this script doesn’t spin the wheel, why?

local prox = script.Parent.wheel.ProximityPrompt
local value = script.Parent.wheel.Value
prox.Triggered:Connect(function()
    if value == "false" then
        value = "true"
        for i = 1, 10, 1 do
            script.Parent.wheel.CFrame = script.Parent.wheel.CFrame * CFrame.fromEulerAnglesXYZ(0.5,0,0) * CFrame.new(0, 0, 0)
            wait(.05)
        end
    else
        value = "false"
        for i = 1, 10, 1 do
            script.Parent.wheel.CFrame = script.Parent.wheel.CFrame * CFrame.fromEulerAnglesXYZ(-0.5,0,0) * CFrame.new(0, 0, 0)
            wait(.05)
        end

    end
end)

Thanks for reading!

I’m assuming the value is a boolvalue, so make sure your values are inputted correctly.

local prox = script.Parent.wheel.ProximityPrompt
prox.Triggered:Connect(function()
	local value = script.Parent.wheel.Value
	if value == false then
		value = true
		for i = 1, 10, 1 do
			script.Parent.wheel.CFrame = script.Parent.wheel.CFrame * CFrame.fromEulerAnglesXYZ(0.5,0,0)
			wait(.05)
		end
	else
		value = false
		for i = 1, 10, 1 do
			script.Parent.wheel.CFrame = script.Parent.wheel.CFrame * CFrame.fromEulerAnglesXYZ(-0.5,0,0)
			wait(.05)
		end
	end
end)

If it isn’t a boolvalue, change teh value to a boolvalue

2 Likes

Alright, thanks! It does work now, but it’s only rotating to the left… do you have a solution for that?

local prox = script.Parent.wheel.ProximityPrompt
prox.Triggered:Connect(function()
	local value = script.Parent.wheel.Value
	if value == false then
		script.Parent.wheel.Value = true
		for i = 1, 10, 1 do
			script.Parent.wheel.CFrame = script.Parent.wheel.CFrame * CFrame.fromEulerAnglesXYZ(0.5,0,0)
			wait(.05)
		end
	else
		script.Parent.wheel.Value = false
		for i = 1, 10, 1 do
			script.Parent.wheel.CFrame = script.Parent.wheel.CFrame * CFrame.fromEulerAnglesXYZ(-0.5,0,0)
			wait(.05)
		end
	end
end)

Try now mate

Yep! I changed some things since, it was mislocated, now it works! Thank you!

1 Like