I have this script that I made, that is a LocalScript in the player's backpack, but I didn't realize that you can't use them as LocalScripts, and I'm not really sure on how I can fix this.. Any possible way without major change?
wait(0.1) local Player = game:GetService("Players").LocalPlayer local Timer = Player:WaitForChild("Time") local Badge = game:GetService("BadgeService") if not (Badge:UserHasBadge(Player.userId, 0)) then -- did have a badgeid, just removed it if (Timer) then while wait(60) do Timer.Value = Timer.Value + 1 if (Timer.Value == 1440) then Badge:AwardBadge(Player.userId, 0) -- did have a badgeid, just removed it wait(0.1) Timer.Value = 0 end end end end
Maybe using RemoteFunctions. In server sided script in ServerScriptStorage:
local HasBadge = Instance.new("RemoteFunction",game.ReplicatedStorage) HasBadge.Name = "HasBadge" local AwardBadge = Instance.new("RemoteFunction",game.ReplicatedStorage) AwardBadge.Name = "AwardBadge" local Badge = game:GetService("BadgeService") HasBadge.OnServerInvoke = function(player, badge) return Badge:UserHasBadge(player.UserId,badge) end AwardBadge.OnServerInvoke = function(player,badge) Badge:AwardBadge(player.UserId,badge) end
In Your Localscript:
wait(0.1) local Player = game:GetService("Players").LocalPlayer local Timer = Player:WaitForChild("Time") local HasBadge = game.ReplicatedStorage:WaitForChild("HasBadge") local AwardBadge = game.ReplicatedStorage:WaitForChild("AwardBadge") --My Notes: InvokeServer inputs player argument for you if not (HasBadge:InvokeServer(0)) then -- did have a badgeid, just removed it if (Timer) then while wait(60) do Timer.Value = Timer.Value + 1 if (Timer.Value == 1440) then --My Notes: InvokeServer inputs player argument for you AwardBadge:InvokeServer(0) -- did have a badgeid, just removed wait(0.1) Timer.Value = 0 end end end end