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

My sword won't inflict damage to others?

Asked by
Jxdenx 45
6 years ago

I think it's a problem with my RemoteEvent script, I'm not really sure but here are the scripts.

LocalScript:

1local tool = script.Parent
2 
3tool.Equipped:connect(function(mouse)
4    mouse.Button1Down:connect(function()
5       tool.Kill:FireServer()
6            end)
7    end)

Script:

01script.Parent.Kill.OnServerEvent:Connect(function()
02    script.Parent.union.Touched:Connect(function(hit)
03        if script.Parent.CanDamage.Value == true and hit.Parent:FindFirstChild("Humanoid") and hit.Parent:FindFirstChild("Creator") == nil then
04        local bloodarea = {"UpperTorso", "LowerTorso", "Head"}
05        local bloodface = {"Top", "Bottom", "Front", "Back", "Left", "Right"}
06        local chosenarea = bloodarea[math.random(1,#bloodarea)]
07        local chosenface = bloodface[math.random(1,#bloodface)]
08        local blood = game.ReplicatedStorage.Blood:Clone()
09        local creator = Instance.new("IntValue")
10        creator.Name = "Creator"
11        creator.Parent = script.Parent.Parent
12        blood.EmissionDirection = chosenface
13        blood.Parent = hit.Parent[chosenarea]
14        script.Parent.CanDamage.Value = false
15        hit.Parent.Humanoid:TakeDamage(100)
16    end
17    end)
18end)
0
Use connect; Connect is deprecated. Also, if you want your sword to work with mobile as well, you should probably use tool.Activated on line 4 of the LocalScript. lunatic5 409 — 6y
0
Well, not just mobile. On all platforms. lunatic5 409 — 6y
0
That didn't solve my problem, thanks though. Jxdenx 45 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

I know making a new script is unefficient but I don't know how to script that well and what you are doing above is kind of hard to read. I honestly think it is a lot less challenging to use this script than to use an event. Make sure if you use my script that it is in a server script located under your sword's handle. It has a debounce if you don't want it to immeadiately kill someone it won't. This script might seem stupid but I hope it helps you.

-- DominusInfinitus

01function debounce(func)  --Debounce optional
02    local isRunning = false   
03    return function(...)      
04        if not isRunning then
05            isRunning = true
06 
07            func(...)         
08 
09            isRunning = false
10        end
11    end
12end
13 
14local Activater = script.Parent.Parent
15local damagePack = script.Parent
View all 44 lines...
0
Oh wow, your script worked! Thanks a lot! Jxdenx 45 — 6y
0
your welcome RetroGalacticGamer 331 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

I don't think You added this at the beginning of both the localScript and Script

1-- I am assuming "Kill" is the RemoteEvent and it should be in ReplicatedStorage
2local RepStorage = game:GetService('ReplicatedStorage')
3local Kill = RepStorage.Kill
4-- Put this in first place
0
First Line* RichCookieGamer 7 — 6y
0
That didn't work, thanks tho Jxdenx 45 — 6y

Answer this question