This is the code that I have and I am not sure how to fix it, I have tried switching the type it is in, but that just adds another error.
local YesButton = script.Parent
local sampleDataStore = game:GetService("DataStoreService"):GetDataStore("SaveData")
YesButton.MouseButton1Click:Connect(function(Player)
local playerKey = "Player_" .. Player.UserId
local success, val = pcall(function()
return sampleDataStore:RemoveAsync(playerKey)
end)
if success then
print(val)
end
end)

2 comments
use game.Players.LocalPlayer.UserId, MouseButton1Click doesn't have any parameters, the word "Player" is just nil
You can't access DataStore in LocalScripts, you should try making a RemoteEvent fire to server and save your data when MouseButton1Click is pressed. You might need to implement a player parameter for the RemoteEvent too