Hey everyone, so im trying to figure out how I can check to see if a player liked my game like sorta how the game rivals dose it any ideas?
local Players = game:GetService("Players")
local GameService = game:GetService("GameService")
local TweenService = game:GetService("TweenService")
local inviteButton = script.Parent
local player = Players.LocalPlayer
-- All Popups --
local PopUpModule = require(game.ReplicatedStorage.Modules.PopUp)
local colorseq = ColorSequence.new({
ColorSequenceKeypoint.new(0, Color3.new(1, 1, 1)),
ColorSequenceKeypoint.new(1, Color3.new(0.7, 0.7, 0.7)),
})
-- Warning Ones
local propertiesBad = {
["Sound"] = game.SoundService:FindFirstChild("SoundBad"), -- plays sound when sending pop up
["Gradient"] = {Color = colorseq, Rotation = 90}, -- use custom gradient
}
-- Good Ones
local propertiesGood = {
["Sound"] = game.SoundService:FindFirstChild("SoundGood"), -- plays sound when sending pop up
["Gradient"] = {Color = colorseq, Rotation = 90}, -- use custom gradient
}
-- Bad Ones
local function tween(object, tweenInfo, propertiesBad)
return TweenService:Create(object, tweenInfo, propertiesBad)
end
-- Good ones
local function tween(object, tweenInfo, propertiesGood)
return TweenService:Create(object, tweenInfo, propertiesGood)
end
-- End Of Popups --
-- Adding sound assets
local hoverSound = inviteButton:WaitForChild("HoverSound")
local clickSound = inviteButton:WaitForChild("ClickSound")
-- Function to handle the click event
local function handleButtonClick()
-- Check if the player is valid
if not player then
return
end
-- Check if the player has liked the game
local success, hasLiked = pcall(function()
return GameService:PlayerHasLikedAsync(player.UserId)
end)
if success and hasLiked then
-- Give 50 coins to the player
-- Replace this with your actual coin giving logic
-- For example:
-- CoinsModule:GiveCoins(player, 50)
PopUpModule.Pop.Local("You've earned 50 coins!", Color3.new(0, 1, 0.117647), 3, {"Fade", "Fade"}, propertiesGood)
else
-- Prompt the player to like the game
PopUpModule.Pop.Local("Please like our game to earn rewards!", Color3.new(1, 0, 0), 3, {"Fade", "Fade"}, propertiesBad)
end
end
-- Connect button events
inviteButton.MouseEnter:Connect(function()
hoverSound:Play()
tween(inviteButton.UIScale, TweenInfo.new(0.08), {Scale = 1.05}):Play()
end)
inviteButton.MouseLeave:Connect(function()
tween(inviteButton.UIScale, TweenInfo.new(0.08), {Scale = 1}):Play()
end)
inviteButton.MouseButton1Down:Connect(function()
clickSound:Play()
tween(inviteButton.UIScale, TweenInfo.new(0.08), {Scale = 0.95}):Play()
end)
inviteButton.MouseButton1Up:Connect(function()
tween(inviteButton.UIScale, TweenInfo.new(0.08), {Scale = 1.05}):Play()
end)
inviteButton.MouseButton1Click:Connect(handleButtonClick)