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

How can I stop the camera from spinning and delete the TextButton when clicked?

Asked by 5 years ago

Ok, so I have a script that when the player joins the game is blur's there screen and it's camera circle's around the baseplate. When pressed a button called "TextButton" the blur affect will be deleted and the camera will resort back to the players humanoid. Although the Camera is still spinning around the player's humanoid. I've tried using a Bool Value to stop the Spinning but the bool only works when the player joins so it wouldn't work. Is there any other way that it will work?

Server Script

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        script.LocalScript:clone().Parent = character
    end)
end)

Spin LocalScript

Bool = true
 local Player = game.Players.LocalPlayer

local hool = Instance.new("BoolValue")
hool.Parent = Player
hool.Name = "Bool"
hool.Value = false
if hool == true then
    Bool = true
end
hool.Value = false

if hool == false then
    Bool = false
end

    local target = workspace.BasePlate
    local camera = workspace.CurrentCamera
    camera.CameraType = Enum.CameraType.Scriptable
    camera.CameraSubject = target
    --camera.Focus = CFrame.new(target.Position)
    local angle = 0
    local i = 0
local blur = Instance.new("BlurEffect")
blur.Parent = camera
blur.Name = "Blur"


    while Bool do
    wait()
        camera.CoordinateFrame = CFrame.new(target.Position)  --Start at the position of the part
        * CFrame.Angles(0, angle, 0) --Rotate by the angle
        * CFrame.new(0, 200, 500)       --Move the camera backwards 5 units
        --camera.Focus = CFrame.new(target.Position)
        angle = angle + math.rad(1)
    end

Stop Spin LocalScript

local Player = game.Players.LocalPlayer

script.Parent.ScreenGui.TextButton.MouseButton1Down:Connect(function()
    local camara = workspace.CurrentCamera:Destroy()
local bool = Player:FindFirstChild("Bool")
bool = false
    camara:FindFirstChild("Blur"):Destroy()
camara.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
camara.CameraType = "Custom"
end)

Answer this question