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

Touch only once activateable? How to fix that?

Asked by 5 years ago

I can only activate the touch one time if I leave my shop it won't open again The trigger script:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        game.ReplicatedStorage.TriggerCam:FireClient(player)

    end
end)

And the gui open script:

game.ReplicatedStorage.TriggerCam.OnClientEvent:Connect(function()
    local player = game.Players.LocalPlayer
    local Shop = workspace.Shop
    local camera = workspace.Camera
    local Open = game.StarterGui.Shop.Open
    local Closed = game.StarterGui.Shop.Closed  
    if Closed.Value == false then
        if Open.Value == false then
            Open.Value = true
            script.Parent.Shop.Frame:TweenPosition(UDim2.new(0,0,0,0))
            camera.CameraType = Enum.CameraType.Scriptable
            camera.CameraSubject = Shop.Cam1
            camera.CFrame = Shop.Cam1.CFrame
        end
    end
end)

And the close script:

script.Parent.MouseButton1Click:Connect(function()
    local player = game.Players.LocalPlayer
    script.Parent.Parent:TweenPosition(UDim2.new(10, 100,0, 0))
    script.Parent.Parent.Parent.Open.Value = false
    local camera = workspace.Camera
    script.Parent.Parent.Parent.Closed.Value = false
    script.Parent.Parent.Parent.Item.Value = 1
    camera.CameraType  = Enum.CameraType.Custom
    camera.CameraSubject = player.Character.Humanoid
    camera.CFrame = player.Character.Head.CFrame
end)

Answer this question