You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
making this script a little more efficient -
What is the issue? Include screenshots / videos if possible!
well I want more efficiency + not have errors for some of the if statements (like if the model doesn’t have a primary part) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’m sorta thinking I should add debounce for the whole area (debounce when activated) because the animation will keep playing even if DB
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
--variables
local player = tool.Parent
local range = game.ServerStorage.Random.GBhitr
local slice = hum:LoadAnimation(amm2)
--running
slice:Play()
local cpy = range:Clone() -- range is the hit range of the gear, this is about where it should be
local offset = Vector3.new(0, 0, -5)
cpy.CFrame = player.PrimaryPart.CFrame*CFrame.new(offset)
cpy.Parent = player
-- weld range and player
local weld = Instance.new("WeldConstraint", cpy)
weld.Part0 = cpy
weld.Part1 = player.PrimaryPart
local takedam = true
cpy.Touched:Connect(function(hit) -- if detects if anything is in the hit range
if hit.Parent:IsA("Model") then -- if model
if hit.Parent.PrimaryPart.Name == ("HumanoidRootPart") then -- has a root
if takedam == true then -- sorta a debounce i think?
takedam = false
local target = hit.Parent:FindFirstChild("Humanoid")
target.Health = target.Health / 2
print(target.Name)
wait(5)
takedam = true
canhit = true
elseif takedam == false then return end
elseif not hit.Parent.PrimaryPart.Name == ("HumanoidRootPart") then return end
elseif not hit.Parent:IsA("Model") then return end
edit: forgot to mention the script is an inside tool.Activated
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.