I spent an hour trying to figure this out and its going to drive me insane here's the code I got
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
local UserInputService = game:GetService("UserInputService")
local Part = script.Parent
function yes()
print("ok")
UserInputService.InputBegan:Connect(function(InputObject, Processed)
if InputObject.KeyCode == Enum.KeyCode.E then
print("got key!")
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-points",player.leaderstats.Points.Value)
end)
if success then
print("Player Data saved!")
else
print("Player Data cant be saved")
warn(errormessage)
end
end)
end
end)
end
script.Parent.Touched:Connect(yes)
Its getting the player touching the block but not the key press. Much help appreciated!
