Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doesn't this script work properly, It's supposed to fire the event if the player owns gp?

Why doesn't this script work properly, It's supposed to fire the event if the player owns the gamepass

game.Players.PlayerAdded:Connect(function(Player)
if game:GetService("GamePassService"):PlayerHasPass(Player,892452203) then
	game.ReplicatedStorage.PetRemotes.GivePet:FireClient("GivePet")
end
end)

1 answer

✓ Accepted answer

You need to utilize WaitForChild() and FireClient needs the client you're referencing to be the first argument.

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PetRemotes = ReplicatedStorage:WaitForChild("PetRemotes")
local GivePet = PetRemotes:WaitForChild("GivePet")

game.Players.PlayerAdded:Connect(function(Player)
	if game:GetService("GamePassService"):PlayerHasPass(Player,892452203) then
		GivePet:FireClient(Player, "GivePet")
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.