So, in my game when I switch tools fast or if I switch them a bunch of times, they will break and of course not work anymore. Because of that I would like to have a script that removes the tools lets say every 15 seconds, and then replaces them in the same order. So if I had a sword in the first slot, a bomb in the second & a rocket in the third then it would replace them in that order instead of rocket in first, bomb in second & sword in last. My game uses R6 avatars and I have 3 tools that I need to be regenerated (not actually a bomb, sword & rocket). and I'm also not very good with scripting right now because I'm a beginner so my code may look terrible.
Workspace.RegenWeapons:13: attempt to index global 'player' (a nil value)
is the error I get.
local sc = game.ReplicatedStorage.Scar local ps = game.ReplicatedStorage.PShotgun local de = game.ReplicatedStorage.Deagle local csc = sc:Clone() local cps = ps:Clone() local cde = de:Clone() player = game.Players.LocalPlayer while true do wait(15) player.Backpack.Scar.Destroy() player.Backpack.PShotgun.Destroy() player.Backpack.Deagle.Destroy() csc.Parent = player.Backpack cps.Parent = player.Backpack cde.Parent = player.Backpack end
Aren't I stupid? Found the fix for the error. Not sure if the script actually works though. Fix was that game.Players.LocalPlayer only works in Local Scripts and I forgot.