Picking up this weapon / having it spawned in my inventory makes it as if it's disabled - the cursor doesn't change, and the scripts inside don't run. I'm wondering if this is an issue with my script or not? These are the opening lines;
game.Players.LocalPlayer.CharacterAdded:wait() local player = game.Players.LocalPlayer local char = player.Character local mouse = player:GetMouse() local tool = script.Parent local handle = script.Parent.Handle local reloading = false local equipped = false script.Parent.Equipped:Connect(function() equipped = true end) script.Parent.Unequipped:Connect(function() equipped = false end) local mag = script.Parent.Handle.mag local clip = script.Parent.Handle.clip local outOfAmmo = false local magMax = 50 local clipMax = 10 local debounce = false local ignore = {workspace.doNotCollide,player.Character}
Thanks.
The problem here is that the script is waiting for the character to spawn - when the script runs, the character already exists, so the code waits until the player respawns (but you won't be able to tell since the tool gets removed just before the new character is made).
So:
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() -->> Character does not exist, it will wait for it to spawn -->> But if it does exist, it simply sets the variable and no yielding happens
Hope I helped!
~TDP