I have been Banging my head on a wall trying to figure out why This local script is not repeating when the player dies.
First I should say, this is a custom HotBar Gui. Yes, the script Does work. It just stops working when the player dies or resets.
After a week of testing to PinPoint the Bug, I have Concluded that something inside of-
function hotbarKey(Slot)
-is Causing this bug.
(Video)
(Server Script)
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function()
RemoteEvent:FireClient(plr)
end)
end)
(Local Script)
local plr = game.Players.LocalPlayer
local RemoteEvent = game.ReplicatedStorage.Folder.RemoteEvent
local RemoteEvent2 = game.ReplicatedStorage.Folder.RemoteEvent2
local StrNum = {["One"] = "1", ["Two"] = "2", ["Three"] = "3", ["Four"] = "4", ["Five"] = "5", ["Six"] = "6", ["Seven"] = "7", ["Eight"] = "8", ["Nine"] = "9"}
local tools = {}
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
local SelectedSlot = 0
function hotbarKey(Slot)
print(Slot)
for i, v in pairs(MainFrame:GetChildren()) do if v.ClassName == "ImageButton" then v.SlotName.TextColor3 = Color3.fromRGB(255,255,255) v.BackgroundColor3 = Color3.fromRGB(104, 104, 104)end end --v.ToolName.TextColor3 = Color3.fromRGB(255, 255, 255)
for i, v in pairs(plr.Character:GetChildren()) do if v:IsA("Tool") then v.Parent = plr.Backpack end end
for i, v in pairs(tools) do
if not v:FindFirstChild("SlotName") then return end
if v.SlotName.Value == Slot.Name then
v.Parent = plr.Character
--print(plr)
end
end
SelectedSlot = tonumber(Slot.SlotName.Text)
Slot.SlotName.TextColor3 = Color3.fromRGB(0, 170, 255)
Slot.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
--Slot.ToolName.TextColor3 = Color3.fromRGB(46, 46, 46)
end