So I made a local script to destroy a part, I know how to do that, but I do I see if the player bought the gamepass.
On local script 1 the player buys the gamepass, but on local script 2 he needs to notice it, how do I do that, Because I can’t sent a remote event from client to client.
You can use a bindable event. Works just like a remote event, only it’s server → server or client → client.
Also, consider merging the scripts; if all you’re doing is destroying a part, you don’t need a separate script for that.
Actually you can send a remote client to client (kind of).
1st remote triggers a sever script that then fires a remote to the client.
This is a server script that can do both of what you’re asking … securely. As all thing that involves a payment should be.
-- server script in ServerScriptService
local Players = game:GetService("Players")
local MarketPlaceService = game:GetService("MarketplaceService")
local gamepassID = ?????? -- GamePass
function Spawned(player)
task.wait(1.1) local HasGamepass = false
local success, message = pcall(function()
HasGamepass = MarketPlaceService:UserOwnsGamePassAsync(player.userId, gamepassID)
end)
if not success then
warn("Checking Gamepass "..tostring(message)) -- this was for testing
return
end
if HasGamepass == true then -- Has the GamePass
-- do what you will. this is also triggered on a log in
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
Spawned(player)
end)
end)
You could modify this to fire back to the client if that is what you wish to do.