Game Creator only gets bonus coin and getting Notified but not everyone on the server?

  1. What do you want to achieve? Keep it simple and clear!

Hello, my objective is to make a Owner join notification. So, basically I have a playeradded event in server script that check if the player UserId Matched with the OwnerUserId if it does it will give everyone in the server bonus coins then a remote event will fire to the localscript and show the Notification Gui otherwise it will print("Owner not found!")

  1. What is the issue? Include screenshots / videos if possible!

Okay, so I got my alt with me and I’m in the game. When my main account joins which is the Owner of the game my alt suppose to get the bonus coins the same goes to everyone in the server and get notified that I have met a Creator instead my main is the only one that get it.

This is what it suppose to look like when a game creator joins the game.

-- ServerScript

local tween = game:GetService("TweenService")
local Check = game.ReplicatedStorage.Events:WaitForChild("Check")
local PlayCoinsSound = game.ReplicatedStorage.Events:WaitForChild("PlayCoinsSound")
local BonusValue = 10000
local OwnerUserId = 1533601134

game.Players.PlayerAdded:Connect(function(player)
	local Folder = Instance.new("Folder")
	Folder.Name = "leaderstats"
	Folder.Parent = player
	local Coins = Instance.new("IntValue")
	Coins.Name = "Coins"
	Coins.Parent = Folder    
	
	if player.UserId == OwnerUserId then
		print("Owner has joined the game!")
		Coins.Value = BonusValue
		PlayCoinsSound:FireAllClients()
		print("Coins Successfully Given to Players!")
		
		Check:FireAllClients()
	else
		print("Owner hasn't join the game yet!")
	end
end)
-- LocalScript

local player = game.Players.LocalPlayer
local tween = game:GetService("TweenService")
local Check = game.ReplicatedStorage.Events:WaitForChild("Check")
local PlayCoinsSound = game.ReplicatedStorage.Events:WaitForChild("PlayCoinsSound")
local ReceivedCoinsSound = game.ReplicatedStorage.SoundModule:WaitForChild("ReceivedCoins")
local Frame = script.Parent:WaitForChild("Frame")
local Notifier = script.Parent.Frame:WaitForChild("TextLabel")
local OwnerUserId = 1533601134
local RunTime = 10

local C = Frame.UIGradient.Rotation
local X = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, -1 ,false, 0.1)
local G = {Rotation = C + 360}
local P = tween:Create(Frame.UIGradient, X, G)
P:Play()

PlayCoinsSound.OnClientEvent:Connect(function()
	ReceivedCoinsSound:Play()
end)

Check.OnClientEvent:Connect(function()
	print("Double Checking Authentication")
	if player.UserId == OwnerUserId then
		print("Successful! " .. OwnerUserId)
		Notifier.Text = "🎉Congratulations you met a creator and you received a bonus of 10,000 Coins!🎉"
		print("Showing Notification")
		local H = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
		local W = {BackgroundTransparency = 0, TextTransparency = 0}
		local M = tween:Create(Notifier, H, W)
		M:Play()
		local T = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0)
		local E = {BackgroundTransparency = 0}
		local S = tween:Create(Frame, T, E)
		S:Play()
		task.wait(RunTime)
		print("Making Notifier Disappear")
		local A = TweenInfo.new(.8, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
		local O = {BackgroundTransparency = 1, TextTransparency = 1}
		local B = tween:Create(Notifier, A, O)
		B:Play()
		local F = TweenInfo.new(.8, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
		local L = {BackgroundTransparency = 1}
		local J = tween:Create(Frame, F, L)
		J:Play()
	else
		print("Failed to find " .. OwnerUserId)
	end
end)

Please help me if you have an answer or a solution to this. Tysm! :slight_smile:

You should probably account for all the Players inside the current game by using a i, v in pairs() loop

-- ServerScript

local tween = game:GetService("TweenService")
local Check = game.ReplicatedStorage.Events:WaitForChild("Check")
local PlayCoinsSound = game.ReplicatedStorage.Events:WaitForChild("PlayCoinsSound")
local BonusValue = 10000
local OwnerUserId = 1533601134

game.Players.PlayerAdded:Connect(function(player)
	local Folder = Instance.new("Folder")
	Folder.Name = "leaderstats"
	Folder.Parent = player
	local Coins = Instance.new("IntValue")
	Coins.Name = "Coins"
	Coins.Parent = Folder    
	
	if player.UserId == OwnerUserId then
		print("Owner has joined the game!")

        for _, Plr in pairs(game.Players:GetPlayers()) do
            local Coins = Plr:WaitForChild("leaderstats"):WaitForChild("Coins")
            Coins.Value = BonusValue
        end

		PlayCoinsSound:FireAllClients()
		print("Coins Successfully Given to Players!")
		
		Check:FireAllClients()
	else
		print("Owner hasn't join the game yet!")
	end
end)

Although do keep in mind though that this would only set everyone’s Coin Value to 1,000, if you wanted to add in relation to every individual Player’s Coins you could do +=

1 Like

Hey, if I want to do everything on a server to prevent easily exploited. How do I access the PlayerGui?

1 Like

It depends, but say if you had a Player variable already in store, you would just simply reference the Player.PlayerGui

local PlayerGui = Player:WaitForChild("PlayerGui")

Keep in mind that exploiters can only view & change what’s replicated (ReplicatedFirst, workspace, ReplicatedStorage, etc) across their side, so if you wanna secure your scripts and such, you could just place them in either ServerScriptService (Which is where Scripts also work there), or ServerStorage for other misc objects