Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Im trying to make this a sword combat script, but it's not working. Is everything properly wrote?

Asked by 4 years ago

I've been trying to do a sword deal damage with animation but i can only use it once for some reason. Here's the script

local script:

local Tool = script.Parent

script.Parent.Activated:connect(function()
    Tool.RemoteEvent:FireServer()
end)

script:

local Tool = script.Parent;
local usable = true
local Part = Tool.Handle.HitPart

Tool.RemoteEvent.OnServerEvent:Connect(function(Player)
    if usable == true then
    usable = false
local player = script.Parent.Parent
local hum = player.Humanoid

local a = player.Humanoid:LoadAnimation(Tool.Throw)
a:Play()
local ten = true

Part.Touched:Connect(function(hit)
    if not ten then return end
 ten = false
    local ehum = hit.Parent:findFirstChild("Humanoid") or hit.Parent.Parent:findFirstChild("Humanoid")
 if ehum and ehum ~= hum then
                ehum:TakeDamage(15)
                wait(0.2)
                usable = true           
    end
end)
end
end)



1 answer

Log in to vote
0
Answered by 4 years ago

Okay so the problem is on line script (not local script) it says: local Tool = script.Parent; the reason it doesnt work is because you put a semi-colon after Parent at the end of the line.

the proper way is: local Tool = script.Parent;

0
It's not the problem, still not working properly Nanzito123 -1 — 4y
Ad

Answer this question