Hello! I am Dev_Asher and I am working on a find the markers game remake, I made a script where when the player touched a marker or in this case Bunny, it fires a remote event to the client where it will reward the player for finding the Bunny. I have most of it down but I now need some way to create a value of the bunny and save it when the player leaves so that when they join back in, their progress is saved.
Here is the code I have so far
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Players = game:GetService('Players')
local BunnyFolder = workspace:WaitForChild('BunnysFolder')
local ReplicatedModules = require(ReplicatedStorage:WaitForChild('Modules'))
local RemoteModule = ReplicatedModules.RemoteService
local BunnysModule = ReplicatedModules.Bunnys
local SystemsContainer = { }
local Debounce = { }
local BunnyTouchedEvent : RemoteEvent = RemoteModule:GetRemote('BunnyTouched', 'RemoteEvent', false)
local Module = { }
local CoolDown = false
function Module:HandleBunny(BunnyName)
for i, Bunny in pairs(BunnyFolder:GetChildren()) do
if Bunny:IsA('Part') and Bunny.Parent == BunnyFolder then
Bunny.Touched:Connect(function(Hit)
if CoolDown == false then CoolDown = true
local LocalPlayer = Players:GetPlayerFromCharacter(Hit.Parent)
BunnyTouchedEvent:FireClient(LocalPlayer, Bunny)
local Interface = LocalPlayer.PlayerGui:WaitForChild('Ui_Interface')
local BunnyFoundFrame = Interface:WaitForChild('BunnyFound')
local Inventory = Interface:WaitForChild('Inventory')
local Backpack = Inventory.InventoryFrame.Backpack
local LHUD = Interface:WaitForChild('LHUD')
BunnyFoundFrame.Visible = true
LHUD.Visible = false
BunnyFoundFrame.Icon.Image = Bunny:WaitForChild('Image').Texture
BunnyFoundFrame.Title.Text = Bunny:WaitForChild('Name').Value
BunnyFoundFrame.Title.TextColor3 = Bunny:WaitForChild('Color').Value
wait(3.5)
for i, selectedFrame in pairs(Backpack:GetChildren()) do
if selectedFrame:IsA('Frame') then
if selectedFrame.Name == Bunny.Name then
selectedFrame.Icon.ImageColor3 = Color3.fromRGB(255, 255, 255)
end
elseif not selectedFrame:IsA('Frame') then
warn('Not A Frame, Must be UiStroke or UiPadding or UiGridLayout')
end
end
BunnyFoundFrame.Visible = false
LHUD.Visible = true
CoolDown = false
end
end)
else
warn('Touched Part Not From Bunny Folder')
end
end
end
function Module:Init(otherSystems)
SystemsContainer = otherSystems
end
return Module
This script is inside another script that calls the function and both scripts are inside server script service