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 a Bunny, it fires a remote event to the client where it will reward the player for finding the Bunny. But the icon won’t show as the bunny that was touched, for example, if I were to touch a Grey bunny it would show it correctly but then if I were to touch a purple bunny, it would show the grey bunny again. How would I fix this?
here is the script
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 selectedData = nil
local Module = {}
function Module:BunnyStack(BunnyID)
return {
ID = BunnyID,
UUID = HTTPService:GenerateGUID(false)
}
end
function Module:SetProperties(parent, propertiesTable, name)
local title = parent:FindFirstChild("Title")
local icon = parent:FindFirstChild("Icon")
if icon then
icon.Image = propertiesTable.Display.Icon
end
if title then
title.Text = propertiesTable.Display.Title.Text
end
end
local DB = false
function Module:CheckBunnyFromID(BunnyID, BunnyName)
for i, Bunny in pairs(BunnyFolder:GetChildren()) do
if Bunny:IsA('Part') and Bunny.Parent == BunnyFolder then
Bunny.Touched:Connect(function(Hit)
if DB == false then DB = true
local LocalPlayer = Players:GetPlayerFromCharacter(Hit.Parent)
BunnyTouchedEvent:FireClient(LocalPlayer, Bunny)
local Interface = LocalPlayer:WaitForChild('PlayerGui'):WaitForChild('Ui_Interface')
local FoundBunnyUI = Interface:WaitForChild('BunnyFound')
local LHUD = Interface:WaitForChild('LHUD')
local selectedConfig = selectedData and BunnysModule:GetItemConfig(selectedData.ID)
Module:SetProperties(FoundBunnyUI, BunnyID, BunnyName)
wait(0.1)
LHUD.Visible = false
FoundBunnyUI.Visible = true
wait(5)
FoundBunnyUI.Visible = false
FoundBunnyUI.Icon.Image = 'rbxassetid://4617621496'
LHUD.Visible = true
DB = false
end
end)
else
warn('Touched Part Not From Bunny Folder')
end
end
end
function Module:Init(otherSystems)
SystemsContainer = otherSystems
end
return Module