The most profitable devices for sponsor games on Roblox and how to count by script?

Hello, I’d love to know what Devices for advertising your game are most profitable if you want them to buy gamepasses in the game? I will assume that phones, because they have small screens and there is a greater chance that they will buy. Does it make sense to advertise for consoles?

And is it actually possible to create a script for which devices bought which gamepass?

2 Likes

Yeah, I think that’s pretty simple. Just detect the devices using the input mode (UserInputService.TouchEnabled/KeyboardEnabled) and probably screen size as well or some more variables if you can find them to make sure that the device you have detected is accurate.
However, after that, you can label that player with the device detected, and then whenever he purchases any game pass, save it in the data store. You can set up a table for your data store and increment the values. Just an example of how will it look like:

Datastore = {
    ["Mobile"] = 10,
    ["PC"] = 10,
    ["Console"] = 10,
}

That’s what I can think of! Let me know if there is any better idea as well!

Still no idea how to do that, just gives me nothing or errors

If you need infomation there is a roblox doc for how to set your own datastore and, how to use UserInputService so you can detect what device they are on! Let me know if you have questions, and hope this helps!

I actually did played the game with userinput service, but my beloved “nil” pissing me off
(did on my knees)

local UserInputService = game:GetService("UserInputService")
local DataStoreService = game:GetService("DataStoreService")
local playerDataStore = DataStoreService:GetDataStore("PlayerDeviceData")

-- Detect device type and store it
function detectAndStoreDevice(player)
    local deviceType = "Unknown"
    
    if UserInputService.TouchEnabled then
        deviceType = "Mobile"
    elseif UserInputService.KeyboardEnabled then
        deviceType = "PC"
    else
        deviceType = "Console"
    end
    
    -- Store detected device type in data store
    local key = "DeviceType_" .. player.UserId
    playerDataStore:SetAsync(key, deviceType)
end

-- Handle player joined event
game.Players.PlayerAdded:Connect(function(player)
    detectAndStoreDevice(player)
end)

-- Handle game pass purchase event
game.Players.PlayerDataStore:OnUpdate("GamePasses", function(player, key, value)
    local deviceKey = "DeviceType_" .. player.UserId
    local deviceType = playerDataStore:GetAsync(deviceKey)
    
    if deviceType then
        local deviceDataKey = deviceType .. "_GamePasses"
        local currentCount = playerDataStore:GetAsync(deviceDataKey) or 0
        playerDataStore:SetAsync(deviceDataKey, currentCount + value)
    end
end)```

Because you have to use userInputService in a local script, as it is a local service, and the datastore service in a server script. Meaning that you will need to connect a lovely remote event.


From roblox docs on UserInputService:

" Since this service is client-side only, it will only work when used in a LocalScript or a ModuleScript required by a LocalScript. As UserInputService is client-side only, users in the game can only detect their own input - and not the input of others."


From roblox docs on DataStoreService:

" Data stores can only be accessed by game servers, so you can only use DataStoreService within a Script or a ModuleScript that is used by a Script. "

Zero results. I tried with RemoveEvent, nothing.
Script in starterplayerscript (local script):

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("DeviceEvent")

local device

if UserInputService.TouchEnabled then
	device = "Mobile"
elseif UserInputService.KeyboardEnabled then
	device = "PC"
else
	device = "Console"
end

remoteEvent:FireServer(device)

ServerScriptService:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("DeviceEvent")

local dataStore = DataStoreService:GetDataStore("DeviceData")

remoteEvent.OnServerEvent:Connect(function(player, device)
	local success, err = pcall(function()
		local currentData = dataStore:GetAsync(device) or 0
		dataStore:SetAsync(device, currentData + 1)
	end)
	if not success then
		warn(err)
	end
end)

And remotevent name is: DeviceEvent

Edit:


Nope, it doesn’t count when im exactly buying gamepass, just increasing itself when i test the game…
edit2: even after rewrite the whole script its still zero value in datastore

Okay so i figured it out i think, if i did something wrong make sure to reply so i know.
I checked with datastore plugin and it works (as far as i believe datastore)




I’m not sure if that is a bug from roblox studio side, but when i’m trying to also add device “tablet” and test as “tablet” device, it just breaking my script that has pc,mobile,console. Any ideas?