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

Why doesn't my script damage players sometimes?

This script damages any player that is hit by it, but if the player with the weapons stays still it instead passes through them without doing any damage...

local modelstuff = {}
function ontouch(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local model = hit.Parent
local hum = hit.Parent:FindFirstChild("Humanoid")
		if modelstuff[model] then
		return
		else
			local def = hit.Parent:FindFirstChild("Defense").Value
			local dmg = script.Parent.Parent:WaitForChild("Attack").Value - def
			hum:TakeDamage(dmg)
			if hit.Parent:FindFirstChild("Bleed") then
				if hit.Parent:FindFirstChild("Streak") then
					else
				local streak = Instance.new("IntValue")
				streak.Parent = hit.Parent
				streak.Name = "Streak"
				end
				local st = hit.Parent:FindFirstChild("Streak")
				st.Value = st.Value + 1
				hit.Parent:FindFirstChild("Bleed").Dmg.Value = hit.Parent:FindFirstChild("Bleed").Dmg.Value + 1
				hit.Parent:FindFirstChild("Bleed").Time.Value = hit.Parent:FindFirstChild("Bleed").Time.Value + 1
				local bled = hit.Parent:FindFirstChild("Head").Bleed
				bled.TextLabel.Text = "Bleed X".. st.Value
			else
				local bleed = game.ServerStorage.Effects.Bleed:Clone()
				bleed.Disabled = false
				bleed.Parent = hit.Parent
			end
			local h = hit.Parent:FindFirstChild("HumanoidRootPart")
			local bb = game.ServerStorage.Classes.BillboardGui:Clone()
			bb.Parent = h
			local txtlabel = bb:WaitForChild("TextBox")
			if dmg > 20 then
				txtlabel.TextColor3 = Color3.fromRGB(255,0,0)
			end
			txtlabel.Text = tostring(dmg)
		end
		modelstuff[model] = true
		wait(.5)
		modelstuff[model] = false
end
end
script.Parent.DmgBox.Touched:Connect(ontouch)

Please help me, i cant script

8 comments

0

You can't script? How did you make this?

0

I can't script well...

0

I remember having the same problem when making a gun. Idk how ur weapons work, so you should make a script that checks whether hit.Parent is a weapon

0

I don't get it, what do you mean? What would making a script that checks if hit.Parent is a weapon do?

0

models hit, the table of characters hit

0

oh ok. i thought you said a bad word

0

I went ahead and changed the variable name anyway since it did seem like vulgar words. Might I suggest using camel case in the future?

0

Ok, yea sorry i should've changed it

1 answer

✓ Accepted answer

it's because it only triggers when it's "TOUCHED" not when it's in that part

if you want to make it so if it's in the player part it still damages while not moving probably either use "FindPartsInRegion3" or a few scripts that check if parts left or go into a part and add that to the list THEN damage all the players in there with another script

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