Getting and setting data to datastores won't work

So, I have a function to manage datastores in a module script that works with remote events. Right now, if I do GetAsync it returns nil and not the value wanted. Anyone have any ideas on why this is happening? I’ve looked around devforum and google a bit but can’t find a solution.

local Event = game:GetService("ReplicatedStorage"):WaitForChild("Events", WaitForTimeout):WaitForChild("1", WaitForTimeout)
    local DatastoreService = game:GetService("DataStoreService")
    local Datastore = DatastoreService:GetDataStore("Coins")
    
    local Connection 
    
    Connection = Event.OnServerEvent:Connect(function(Player, Key, Action, Value)
        warn(Player, Key, Action, Value)
        local Success, Response = pcall(function()
            if Action == "GetAsync" then
                Event:FireClient(Player, Datastore:GetAsync(Player.UserId.."_"..DatastoreName))
                task.wait()
            elseif Action == "IncrementAsync" then
                Datastore:IncrementAsync(Player.UserId.."_"..DatastoreName, Value)
                task.wait()
            elseif Action == "SetAsync" then
                Datastore:SetAsync(Player.UserId.."_"..DatastoreName, Value)
                task.wait()
            end
        end)
        
        if not Success then
            warn(Response)
        end
        
        task.wait()
        Connection:Disconnect()
    end)

Well, first I should mention, that this solution is definitely not good idea, as I read, you’re giving players a permission to write to your datastore whatever they want. Exploiters could definitely break your game easily.

Do you receive a warn log in your console? If yes, then wrap up your datastore calls with a pcall and check if any error occurred. Also pcall guarantees that your datastore call has been finished, so if you’re calling set and then get right away, then this will return a null value since the datastore has not finished saving your data yet.

Try to debug your code using breakpoints or insert proper logs.

It’s in a pcall and the event is just to allow client > server

Edit:

Just realized I don’t need to do it on client so solved, thanks