Can someone help me with this? I want to make it so that when a player dies they drop a gun and it left the ammo (ex: if player have 2 bullets left out of six when other people pick it up it’ll still be 2)
But this is my script
local DropEvent = script.Parent.DropEvent
local RS = game:GetService("ReplicatedStorage")
DropEvent.OnServerEvent:Connect(function(plr, Action, Bulletsleft, tool) --Bulletsleft in this case is like 2-3-4 or whatever
if Action == "Used" then
script.Parent:Destroy()
elseif Action == "Died" then
local newtool = tool:Clone()
newtool.Parent = RS.TempStorage
local GunModule = require(newtool.GunMod)
GunModule.CurrentMag = Bulletsleft
local GunModel = RS.Models.RevolverDrop:Clone()
GunModel.Tool.Value = newtool
GunModel.Ammo.Value = Bulletsleft
GunModel.Parent = plr.Character.Parent
GunModel:PivotTo(plr.Character.PrimaryPart.CFrame)
end
end)
local ProximityPrompt = script.Parent
local toolVal = script.Parent.Parent.Tool
local ammoVal = script.Parent.Parent.Ammo
local RS = game:GetService("ReplicatedStorage")
ProximityPrompt.Triggered:Connect(function(player)
if player.Team.Name ~= "Civilian" then
return
end
local tool = toolVal.Value:Clone()
tool.Parent = player.Backpack
local GunModule = require(tool.GunMod)
GunModule.CurrentMag = ammoVal.Value
toolVal.Value:Destroy()
script.Parent.Parent:Destroy()
end)
When I pick it up it has full magazine
You can see I tried storing ammo in an instance as well but still no luck (the instance prints properly and return the actual ‘bullets left’ number)
Any help would be great!