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

I'm making a fighting game, but the swords won't work. Please help?

Asked by 4 years ago
local Sword = script.Parent

local function onTouch(partOther)

    local humanOther = partOther.Parent:FindFirstChild("Humanoid")

    if not humanOther then return end

    if humanOther.Parent == Sword then return end

    humanOther:TakeDamage(5)
end

local function slash()

    local str = Instance.new("StringValue")
    str.Name = "toolanim"
    str.Value = "Slash"
    str.Parent = Sword
end

Sword.Activated:Connect(slash)
Sword.Handle.Touched:Connect(onTouch)

2 answers

Log in to vote
0
Answered by
Ascarson4 138
4 years ago

What do you mean it doesn't work. I tested it and it works perfectly fine. Make a tool in StarterPack, add a part to that tool(or your your sword mesh/model, just make sure the handle is a part), name the part "Handle", add a normal script to the tool, paste your code in the script. Test it.

0
I didn't put it in starterPack, I put it in a textbutton in starterGUI because I'm making a button to get a sword. Do you know why it won't work? Thanks. DriBowser 55 — 4y
0
Try putting it in StarterPack and see what happens, and also, what happens when you click the textbutton? Is the entire sword, including the script, cloned into the player's backpack? If so, what kind of script are you using for the sword, is it a server script or a localscript(these are the ones with a person's head on it)? Ascarson4 138 — 4y
0
I did try putting it in starterPack, and it did work, and when I click the text button, it clones everything into it and the animation, but not the original sword animation. I made the other animation myself. Also, I'm using a localScript for the textbutton and the damage script didnt load but the animation script did, and I'm using a normal script for the sword to damage DriBowser 55 — 4y
0
Nevermind, I fixed it. Thank you so much! DriBowser 55 — 4y
0
No problem! Ascarson4 138 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

I just needed to change the damage script in the sword to a local script!

Answer this question