Ad
Log in to vote
0

Remote event doesnt get activated through the type check in my script?

Asked by 15 days ago

In this script I am trying to pass a RemoteEvent once you say "Hello" But nothing is working, and theres no errors.

Script:

local replicatedstorage = game:GetService("ReplicatedStorage")
local RemoteEventConnection = game.ReplicatedStorage:WaitForChild("CommissionTest")
local player = game.Players.LocalPlayer
local GamePassId = 6766156 -- Replace with your gamepass
local WhitelistUserIDs = { --Your PlayerId's here
    79523404,
    0,
    1,
    2
}

if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, GamePassId) == true or table.find(WhitelistUserIDs, player.UserId) then
    print("First")
    function onChatted(message, player)
        if message == "Hello" and game.MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamePassId) then
            print("message sent")
            RemoteEventConnection:FireServer(GamePassId,WhitelistUserIDs)


        end
    end
end



game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player)

    end)
end)
0
Is this a client script or a server script? cracker_555555555555 0 — 15d
0
its from the client, he uses LocalPlayer in the first few lines BulletproofVast 776 — 15d

1 answer

Log in to vote
1
Answered by 15 days ago

don't really recommend using this from a local script, way more secure while checking on the server, also wouldn't need the remote.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local MarketplaceService = game:GetService('MarketplaceService')
local RemoteEventConnection = ReplicatedStorage:WaitForChild("CommissionTest")
local player = game.Players.LocalPlayer
local GamePassId = 6766156
local WhitelistUserIDs = {
    79523404;
}

function onChatted(message)
    if message == "Hello" then
        print("message sent")
        RemoteEventConnection:FireServer(GamePassId, WhitelistUserIDs)
    end
end

-- makes sure you're allowed to use the command, this one check is enough. don't need to check again in function.
if MarketplaceService:UserOwnsGamePassAsync(player.UserId, GamePassId) or table.find(WhitelistUserIDs, player.UserId) then
    player.Chatted:Connect(onChatted)
end
0
thanks bro snipperdiaper 120 — 15d
Ad

Answer this question