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

How to convert this to onTouch()?

It's Maelstronomer's flip camera upside down button GUI, and I was wanting to know if it was possible to make it onTouch() and then have another brick that makes it reset to the original form.

Here are the scripts that are used (They're local scripts.)

Code 1:

rs = game:GetService("RunService")
c = game.Workspace.CurrentCamera

on=false
script.Parent.MouseButton1Down:connect(function()
	on=not on
	--[[if on then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed =
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed * (-1)
	else
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed =
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed * (-1)
	end--]]
end)

while true do
	if on then
		c.CoordinateFrame = c.CoordinateFrame
		* CFrame.Angles(0, 0, math.rad(180))
		
	end
	rs.RenderStepped:wait()
end

Code 2:

--You can affect roll with CoordinateFrame too(it got secretly added while ago). Proof:

rs = game:GetService("RunService")
t = 0
lastTick = tick()
rotation = 0

while true do
	local dt = tick() - lastTick
	rotation = rotation+math.rad(10*dt)
	game.Workspace.CurrentCamera.CoordinateFrame = game.Workspace.CurrentCamera.CoordinateFrame * CFrame.Angles(0, 0, rotation)
	
	lastTick = tick()
	rs.RenderStepped:wait()
end

1 answer

✓ Accepted answer
rs = game:GetService("RunService")
c = game.Workspace.CurrentCamera

on=false
script.Parent.Touched:connect(function()
    on=not on
    --[[if on then
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed =
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed * (-1)
    else
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed =
        game.Players.LocalPlayer.Character.Humanoid.WalkSpeed * (-1)
    end--]]
end)

while true do
    if on then
        c.CoordinateFrame = c.CoordinateFrame
        * CFrame.Angles(0, 0, math.rad(180))

    end
    rs.RenderStepped:wait()
end

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