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

Why wont this action bind with ContextActionService?

Asked by
epoke466 100
3 years ago
local player = script.Parent.Parent.Parent.Parent

local ContextActionService = game:GetService("ContextActionService")

local datastore = game:GetService("DataStoreService")
local ds1 = datastore:GetDataStore("GlobalLeaderboard_")
local ds2 = datastore:GetDataStore("TotalCapturesOfTheFlag")

local cooldown = script.Parent.Cooldown

local a = script.Parent.a
local b = script.Parent.b
local c = script.Parent.c

repeat
    a.Enabled = true
until
    a.Enabled == true

function save()
    if (cooldown.Value == false) then
        cooldown.Value = true

        a.Enabled = false
        b.Enabled = true

        script.Parent.Text = "Saveing..."
        ds1:SetAsync(player.UserId, player.leaderstats.XP.Value)
        ds2:SetAsync(player.UserId, player.leaderstats:FindFirstChild("Total Captures").Value)
        script.Parent.Text = "Data Saved!"

        b.Enabled = false
        c.Enabled = true

        wait(5)

        c.Enabled = false
        a.Enabled = true

        script.Parent.Text = "Save Data To DataStoreService"
        cooldown.Value = false
    end
    end



--The Problem Is Right Here, I'm trying to bind the function 'Save' for controler
ContextActionService:BindAction("SaveDataxBox", save, false, Enum.KeyCode.ButtonY)
--Bind For xBox
script.Parent.TouchTap:Connect(save)
--Bind For Mobile
script.Parent.MouseButton1Click:Connect(save)
--Bind For PC

Answer this question