Hi, I recently made a sword, and I want to ask you: Is this anti-exploitable?
Here’s the script I made for this(Its not a local script):
local state = script.Parent.State
local damage = 33.5
script.Parent.Activated:Connect(function() --Detects when tool is activated, plays animation and changes the state value
if state.Value == "Holding" then
state.Value = "Cooldown"
script.Parent.Parent.Humanoid:LoadAnimation(script.Parent.Animation):Play()
wait(0.2)
state.Value = "Swing"
wait(1.2)
state.Value = "Holding"
end
end)
script.Parent.BladeHitbox.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if state.Value == "Swing" then
state.Value = "Cooldown"
hit.Parent.Humanoid:TakeDamage(damage) -- Take damage to player who touched it
-- Rest of the script is a damage indicator that shows on player's head when hit. --
local part = Instance.new("Part")
part.Transparency = 1
part.Parent = workspace
part.CanCollide = false
part.Anchored = true
part.Position = hit.Parent.Head.Position
local showDamage = game.ServerStorage.BillboardGui:Clone()
showDamage.Parent = part
local damageText = Instance.new("TextLabel")
damageText.Parent = showDamage
damageText.Text = damage
damageText.TextScaled = true
damageText.Size = UDim2.new(1,0,1,0)
damageText.BackgroundTransparency = 1
damageText.TextStrokeTransparency = 0
damageText.TextColor3 = Color3.fromRGB(255,0,0)
wait(0.5)
for i = 0,40,1 do -- A for loop; this is the fade effect for damage indicator
showDamage.ExtentsOffset = showDamage.ExtentsOffset + Vector3.new(0,0.025,0)
damageText.TextTransparency = damageText.TextStrokeTransparency + 0.025
damageText.TextStrokeTransparency = damageText.TextStrokeTransparency + 0.025
wait(0.05)
end
wait(0.1)
part:Destroy()
end
end
end)