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

Not sure why the code wont work, shouldnt itchange the value of the camera and change the camera?

Asked by 4 years ago

Not sure why it wont work, no error code or anything in output. Print works fine and prints. Just doesnt even change the value. Anything to change?

repeat
    wait(0.01)
until game.Players.LocalPlayer

local Player = game.Players.LocalPlayer

--Camera Stuff--
local TweenService = game:GetService("TweenService")

local RunService = game:GetService("RunService")

local CameraStorageFolder = game.Workspace:WaitForChild("CameraBricks"):WaitForChild("ClothingStoreCenturyXHawthorne")  -- The object to rotate around

workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable

workspace.CurrentCamera.CFrame = CameraStorageFolder:WaitForChild("MainCamera").CFrame

local CameraPosition = script.Parent.CameraPos.Value



function UpdateCameraPos()
    print("update")
    workspace.CurrentCamera.CFrame = CameraStorageFolder[CameraPosition].CFrame
end

--CameraChangeFunctions--

local ChangeCameraButtonsFolder = script.Parent.Cameras

--CameraButtons--

ChangeCameraButtonsFolder.HatBack.MouseButton1Click:Connect(function()
    print("click")
    local CameraPosition = "HatBackCamera"
end)

ChangeCameraButtonsFolder.HatFront.MouseButton1Click:Connect(function()
    local CameraPosition = script.Parent.Name.."Camera"
end)

ChangeCameraButtonsFolder.ShirtBack.MouseButton1Click:Connect(function()
    local CameraPosition = script.Parent.Name.."Camera"
end)

ChangeCameraButtonsFolder.ShirtFront.MouseButton1Click:Connect(function()
    local CameraPosition = script.Parent.Name.."Camera"
end)

ChangeCameraButtonsFolder.PantBack.MouseButton1Click:Connect(function()
    local CameraPosition = script.Parent.Name.."Camera"
end)

ChangeCameraButtonsFolder.PantFront.MouseButton1Click:Connect(function()
    local CameraPosition = script.Parent.Name.."Camera"
end)

ChangeCameraButtonsFolder.Main.MouseButton1Click:Connect(function()
    local CameraPosition = script.Parent.Name.."Camera"
end)



--Hat--

--Shirt--

local ShirtFrame = script.Parent.Shirt

local ShirtsAvailable = {}

local ShirtCount = 0

function ChargeForShirt()
    if ShirtFrame.Buying.Value == true then
        print(game.ReplicatedStorage.Clothing.Shirts:FindFirstChild(ShirtFrame.ItemName.Text).Price.Value)
        if game.Players.LocalPlayer.stats.Money.Value >= game.ReplicatedStorage.Clothing.Shirts:FindFirstChild(ShirtFrame.ItemName.Text).Price.Value then
            if game.ReplicatedStorage.Clothing.Shirt:FindFirstChild(ShirtFrame.ItemName.Text).ShirtsTemplate.Value ~= game.Players.LocalPlayer.stats.ShirtID.Value then
                local ShirtItemName = script.Parent.Shirt.ItemName.Text
                game.ReplicatedStorage.ShopEvents.Clothing.BuyShirt:FireServer(ShirtItemName)
                ShirtFrame.Price.Text = "Purchased!"
                wait(5)
            else
                ShirtFrame.Price.Text = "Not Enought Money/Error!"
                wait(5)
            end
        end
    end
end

for i,v in pairs(game.ReplicatedStorage.Clothing.Shirts:GetChildren()) do
    table.insert(ShirtsAvailable,v)
end

function UpdateShirt()
    ShirtFrame.Buying.Value = true
    ShirtFrame.ItemName.Text = ShirtsAvailable[ShirtCount].Name
    ShirtFrame.Price.Text = "$"..ShirtsAvailable[ShirtCount].Price.Value
    Player.Character:WaitForChild("Shirt").ShirtTemplate = ShirtsAvailable[ShirtCount].ShirtTemplate
end

ShirtFrame.LeftShirt.MouseButton1Click:Connect(function()
    if ShirtCount >1 then
        ShirtCount = ShirtCount - 1
        UpdateShirt()
    end
end)

ShirtFrame.RightShirt.MouseButton1Click:Connect(function()
    if ShirtCount >= #ShirtsAvailable then
    else
        ShirtCount = ShirtCount + 1
        UpdateShirt()
    end
end)

ShirtFrame.Revert.MouseButton1Click:Connect(function()
    Player.Character:FindFirstChildWhichIsA("Shirt").ShirtTemplate = Player.stats.ShirtID.Value
    ShirtFrame.ItemName.Text = "None"
    ShirtFrame.Price.Text = "Shirts Price"
    ShirtFrame.Buying.Value = false
end)

--Pants--
function ChargeForPants()
    if script.Parent.Pant.Buying.Value == true then
        print(game.ReplicatedStorage.Clothing.Pants:FindFirstChild(script.Parent.Pant.ItemName.Text).Price.Value)
        if game.Players.LocalPlayer.stats.Money.Value >= game.ReplicatedStorage.Clothing.Pants:FindFirstChild(script.Parent.Pant.ItemName.Text).Price.Value then
            if game.ReplicatedStorage.Clothing.Pants:FindFirstChild(script.Parent.Pant.ItemName.Text).PantsTemplate.Value ~= game.Players.LocalPlayer.stats.PantsID.Value then
                local PantsItemName = script.Parent.Pant.ItemName.Text
                game.ReplicatedStorage.ShopEvents.Clothing.BuyPants:FireServer(PantsItemName)
                script.Parent.Pant.Price.Text = "Purchased!"
                wait(5)
            else
                script.Parent.Pant.Price.Text = "Not Enought Money/Error!"
                wait(5)
            end
        end
    end
end

script.Parent.AcceptAndDecline.Accept.MouseButton1Click:Connect(function()
    ChargeForShirt()
    ChargeForPants()
    workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
    script.Parent.Parent:Destroy()
end)

script.Parent.AcceptAndDecline.Decline.MouseButton1Click:Connect(function()
    workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
    script.Parent.Parent:Destroy()
end)



script.Parent.CameraPos.Changed:Connect(UpdateCameraPos)

Answer this question