Hello! I’m trying to make a script that awards a player a badge if they take a screenshot in the game. I just can’t think of any script. No tutorials, videos, nothing. I know its possible because there is a badge in a game that can do this.
Any Ideas of how to do this?
Any help will be appreciated!
I think this badge was awarded for standing on the photo platform but I may be wrong, this might not be an example of what you want.
I never took a screenshot but still own said badge.
Something like this should do the job:
local player = game.Players.LocalPlayer
local uis = game:GetService("UserInputService")
local id = 12345678
uis.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Print then
game:GetService("BadgeService"):AwardBadge(player.UserId, id)
end
end)
I can’t get it to replicate on Studio, but this is the closest I’ve gotten.
An actual screenshot?
Maybe award the badge when they interact with the camera, it would be simpler
This youtube video might help us
All scripts under StarterPlayerScripts
Module Script:
local userInputService = game:GetService("UserInputService")
local Input = {}
local binds = {}
function Input.BindKeyPresses(name, callback, ...)
local keys = table.pack(...)
keys.n = nil
binds[name] = userInputService.InputBegan:Connect(function(input)
if input.KeyCode and input.KeyCode == keys[#keys] then
for i, key in pairs(keys) do
if not userInputService:IsKeyDown(key) then
return
end
end
callback()
end
end)
end
function Input.UnbindKeyPresses(name)
if binds[name] then
binds[name]:Disconnect()
end
end
return Input
Local Script
local input = require(script.Parent:WaitForChild("Input"))
local badgeId = --Insert badge Id here
input.BindKeyPresses("Test", function()
print("key were pressed")
end, Enum.KeyCode.LeftControl, Enum.KeyCode.T)
if --award badge here
On the line below for the local script, it said there is no such thing as Windows or the PrtSc key.
https://developer.roblox.com/en-us/api-reference/event/DataModel/ScreenshotSavedToAlbum
Unfortunately this event/signal is restricted to CoreScripts.
Sadly, it’s not possible to do that.