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

How to convert this to onTouch()?

Asked by 9 years ago

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

Log in to vote
0
Answered by 9 years ago
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

Ad

Answer this question