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

My Sword script was just working in the game but now it won't work and it only works in studio, why?

Asked by 6 years ago

Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SwordSwingingEvent = ReplicatedStorage:WaitForChild("SwordSwingingEvent")
SwordSwingingEvent.OnServerEvent:connect(function(player)

script.Parent.blade.Touched:connect(function(hit)
 if script.Parent.CanDamage.Value == true then
  script.Parent.CanDamage.Value = false
  if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
    hit.Parent.Humanoid:TakeDamage(30)
  wait(1)
  script.Parent.CanDamage.Value = true
end
end
end)
end)

Local Script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SwordSwingingEvent = ReplicatedStorage:WaitForChild("SwordSwingingEvent")
SwordSwingingEvent:FireServer()
local CanAttack = true
script.Parent.Activated:connect(function()
local attack = script.Parent.Parent.Humanoid:LoadAnimation(script.Attack)
if CanAttack == true then
attack:Play()
CanAttack = false
wait(1)
attack:Stop()
CanAttack = true
script.Parent.CanDamage.Value = true
end
end)

I have a remote event in Replicated Storage labeled "SwordSwingingEvent" and I added it in hopes it would change it but i'm not that skilled with scripting so far so it didn't change anything. There is also a part on my sword labeled 'blade' which is the main part that is meant to damage the player since it covers the blade of the sword. Finally there is a BoolValue labeled CanDamage and it's set to true. I hope I added all the info I needed thank you.

0
I love swords, and it hurts me to see a sword not corresponding to your wishes. You have my condolences, fellow writer. Seventh_doctrine 13 — 6y
0
FE = filtering enabled tacotown2 119 — 6y
0
indent please User#22604 1 — 6y
0
^ lunatic5 409 — 6y
View all comments (3 more)
0
you know you don't need events to build a sword right? You are using very hard scripting methods. RetroGalacticGamer 331 — 6y
0
I know, i'm very bad at scripting, i'm trying to get better but all videos are outdated and I do better watching videos since i'm more of a visual learner. Verscile 0 — 6y
0
If you have a good method for me to try and get myself on my feet and actually understand scripting a bit more, please tell me. Verscile 0 — 6y

Answer this question