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

SetAsync is not a valid member of RemoteEvent?

Asked by 6 years ago

This is my datastore script that checks if a player has played the game before (I'll add more later) but I get a weird error: SetAsync is not a valid member of RemoteEvent

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Save = ReplicatedStorage:WaitForChild("Save")

game.Players.PlayerAdded:connect(function(player)
    local PlayerStats = Instance.new("Folder", player)
    PlayerStats.Name = "PlayerStats"

    local HasJoinedBefore = Instance.new("BoolValue", PlayerStats)
    HasJoinedBefore.Name = "HasJoinedBefore"
    HasJoinedBefore.Value = Save:GetAsync(player.UserId) or false

    Save:SetAsync(player.UserId, HasJoinedBefore.Value)

    HasJoinedBefore.Changed:connect(function()
        Save:SetAsync(player.UserId, HasJoinedBefore.Value)
    end)
end)

game.Players.PlayerRemoving:connect(function(player)
 Save:SetAsync(player.UserId, player.PlayerStats.HasJoinedBefore.Value)
end)


local function save(player)
    player.PlayerStats.HasJoinedBefore.Value = true
    Save:SetAsync(player.UserId, player.PlayerStats.HasJoinedBefore.Value)
end

Save.OnServerEvent:Connect(save)
1
Your save variable leads to a remote event, not the datastore. hiimgoodpack 2009 — 6y
0
how can I fix that? User#20388 0 — 6y

Answer this question