Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Wait for the player's Backpack and required objects
- local player = game:GetService("Players").LocalPlayer
- -- Function to monitor tools and their AMMO
- local function monitorTool(tool)
- if tool.Name == "db" or tool.Name == "rev" then
- local ammoValue = tool:FindFirstChild("AMMO")
- local remoteEvent = tool:FindFirstChild("rl")
- if ammoValue and ammoValue:IsA("NumberValue") and remoteEvent then
- -- Function to check AMMO value
- local function checkAmmo()
- if ammoValue.Value == 0 then
- remoteEvent:FireServer() -- Fire the remote event
- end
- end
- -- Connect to changes in AMMO's Value
- ammoValue:GetPropertyChangedSignal("Value"):Connect(checkAmmo)
- else
- warn("AMMO value or remote event 'rl' not found in the tool:", tool.Name)
- end
- end
- end
- -- Listen for tools in Backpack and Character
- player.Backpack.ChildAdded:Connect(monitorTool)
- player.CharacterAdded:Connect(function(character)
- character.ChildAdded:Connect(monitorTool)
- end)
- -- Check for tools already equipped or in the Backpack
- for _, item in pairs(player.Backpack:GetChildren()) do
- monitorTool(item)
- end
- if player.Character then
- for _, item in pairs(player.Character:GetChildren()) do
- monitorTool(item)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement