local IsDamaged = false -- [ You can also implement variables to set which Body Part is damaged.
function test()
if script.Parent:FindFirstChild('IsPlayerHit') and not (IsDamaged == true) then -- [ debounce
IsDamaged = true
print("hit")
end
end
while wait() do
test()
end
bullet script
local bullet = script.Parent
function tag(char)
local tag = Instance.new('IntValue',char)
tag.Name = 'IsPlayerHit'
end
local TaggedPlayers = {}
bullet.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not table.find(TaggedPlayers,hit.Parent.Name) and not (hit.Parent:FindFirstChild('IsPlayerHit')) then
tag(hit.Parent)
table.insert(TaggedPlayers,hit.Parent.Name)
end
end)
I noticed something btw, Whenever I run this script on the server the module script where the bullet is made doesn’t show on server but shows when its an Instance.new
local laserPart = game.ReplicatedStorage.Bullet
local clonedbullet = laserPart:Clone()
clonedbullet.Parent = workspace
clonedbullet.Size = Vector3.new(0.2,0.2,laserDistance)
clonedbullet.CFrame = laserCFrame
-- Add laser beam to the Debris service to be removed & cleaned up
game.Debris:AddItem(clonedbullet, SHOT_DURATION)
local bullet = script.Parent
function tag(char)
local tag = Instance.new('IntValue',char)
tag.Name = 'IsPlayerHit'
end
local TaggedPlayers = {}
bullet.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and not (table.find(TaggedPlayers,hit.Parent.Name)) and not (hit.Parent:FindFirstChild('IsPlayerHit')) then
tag(hit.Parent)
table.insert(TaggedPlayers,hit.Parent.Name)
end
end)
i forgot to put parenthesis lol wait heres the new one
I still dont know whats going on, and I need to go sorry. By the way, you should try debounce, its a useful variable that you can use to stop spamming.
Try seeing this for a little help!