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

I need help, how do I change the damage of a sword by entering a brick?

Asked by 6 years ago
Edited 6 years ago

My concept is that the damage of the player's sword changes from the value 0 to 30 when you enter a brick. And I would also like to make it so when they leave the brick it changes the value back from 30 to 0 again. I am using the default roblox sword by the way, the LinkedSword. I am having trouble doing this, so I would appreciate some help.

This is what I have so far:

local Arena = game.Workspace.Arena

Arena.Touched:connect(function(hit)

end)


Arena.TouchEnded:connect(function(leave)

end)

1 answer

Log in to vote
0
Answered by 6 years ago

What I would do is setup an int value that is inside the tool.

So first step would be creating a new IntValue inside the tool and naming it damage

Then going into LinkedSword Script

local damage = script.Parent:WaitForChild("damage").Value

Then your going to use in if statement to check if their is a humanoid and if there is then its going to make the IntValue damage value = 30

local Arena = game.Workspace.Arena

Arena.Touched:connect(function(hit)
    if hit:FindFirstChild("Humanoid") then
        hit:WaitForChild("ToolName").damage.Value=30
    end
end)


Arena.TouchEnded:connect(function(leave)
    if leave:FindFirstChild("Humanoid") then
        leave:WaitForChild("ToolName").damage.Value=0
    end
end)

That should work, dont have time to test if there is any errors and you cant figure it out speak with me on discord: Dawn#0666

Ad

Answer this question