✓ Accepted answer
There are a few other ways of getting a player in a global script. You can use this loop to get all players:
Global Script:
function LoopCheck()
for i,v in pairs(game:GetService("Players"):GetPlayers()) do
v.Values.PlayerItemHolds.Changed:connect(function()
local prog = player.Values.PlayerItemHolds
prog.Value = prog.Value + 1
script.Parent:TweenSize(UDim2.new(prog.Value/100, 0, 1, 0), "In", "Bounce", .1)
if prog == 10 then
prog = 0
end
end)
end
end
Or if you don't want to check every player one-by-one, you can use a remote event. What you will do is simple, you will fire the server from the client. You will need two scripts this time, and a remote event.
Global Script:
local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
Event.OnServerEvent:Connect(function(player)
local prog = player.Values.PlayerItemHolds
prog.Value = prog.Value + 1
script.Parent:TweenSize(UDim2.new(prog.Value/100, 0, 1, 0), "In", "Bounce", .1)
if prog == 10 then
prog = 0
end
end)
Local Script:
local Event = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
game.Players.LocalPlayer.Values.PlayerItemHolds.Changed:connect(function()
Event:FireSrver()
end)