Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why wont this gun kill people entirely?(Unanswered)

I made a gun, and it shoots, but when I shoot someone dead, they are still alive on their screen, but on my screen, they are dead but don't respawn, please help me, I've been trying for hours to find a good way to script my gun without having any reloading or GUI stuff, so here's the script:

Player = game.Players.LocalPlayer
mouse = Player:GetMouse()
maxAmmo = 50
ammo = maxAmmo
rate = 0.1
firing = false
Canfire = true
reload = 5
damage = 20
script.Parent.Activated:Connect(function()
	if ammo >= 1 and Canfire == true then
		firing = true
		repeat local bullet = Instance.new("Part", workspace)
			bullet.CanCollide = true
			bullet.Shape = "Ball"
			bullet.Size = Vector3.new(0.4, 0.4, 0.4)
			bullet.Material = "Neon"
			bullet.BrickColor = BrickColor.new("Bright yellow")
			bullet.CFrame = CFrame.new(script.Parent.Handle.Position, mouse.Hit.p)
			local v = Instance.new("BodyVelocity", bullet)
			v.Velocity = bullet.CFrame.LookVector*520
			game.Debris:AddItem(bullet,5)
			bullet.Touched:connect(function(hit)
				if hit.Parent ~= Player.Character and hit.Parent:FindFirstChild("Humanoid") then
					hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - damage
					bullet:Destroy()
				end
			end)
				wait(rate)
		until ammo < 1 or firing == false
	end
end)
script.Parent.Deactivated:Connect(function()
	if firing == true
	then
		firing = false
	end
end)
mouse.KeyDown:connect(function(key)
	if string.lower(key) == "r" and ammo < maxAmmo and firing == false then
		Canfire = false
		wait(reload)
		ammo = maxAmmo
		Canfire = true
	end
end)

1 comment

0

im sorry i brought this back, but my notifications said that my older post about this was answered, but there was no answer when i checked it.

1 answer

✓ Accepted answer

they are still alive on their screen, but on my screen, they are dead but don't respawn

This means you are using a localscript, you will need to use remotefunctions/events and a script to make the damage work, also remember to protect your remotefunction/events!

2 comments

0

i know, but i really dont know how to do that, because i am mega nooby at scripting, so maybe a little bit of instruction to help me?

This discussion is preserved as it was. New answers, comments, and votes are closed.