This script searches for "LogiaImmune" inside of an Accessory when it hits an Accessory, even though it isn't suppose to. I get this error message, when I shouldn't. Any idea why?
Script:
r = game:service("RunService") arrow = script.Parent a = Instance.new("Sound") a.SoundId = "http://www.roblox.com/asset/?id=137463821" a.Parent = arrow a.Volume = 2 a:play() Owner = arrow.Owner torso = game.Workspace:FindFirstChild(Owner.Value.Name).Torso damage = 2 position = arrow.Position function fly() direction = arrow.CFrame.lookVector position = position + (direction*6) error = position - arrow.Position arrow.Velocity = error * 50 end function onTouched(hit) if hit.Parent.Name ~= Owner.Value.Name and hit.Name~="Part" and hit.ClassName~= ("Accessory") and hit.Name~= "Blast" and hit.Name~= "Damage" then humanoid = hit.Parent:findFirstChild("Humanoid") t = hit.Parent:FindFirstChild("Torso") if humanoid~=nil then if humanoid.Parent:findFirstChild("Logia") == nil or humanoid.Parent:findFirstChild("Logia").Value == false and humanoid.Parent:findFirstChild("ForceField") == nil then humanoid.Health = humanoid.Health - damage t.Velocity = torso.CFrame.lookVector * 80 + Vector3.new(0, 0, 0) end if arrow.Name == "HakiPowered" then humanoid.Health = humanoid.Health - damage*2 humanoid.Sit = true wait() humanoid.Sit = false humanoid.Jump = true end wait() end end end function SmokeHit(hit) if hit.Parent.Name ~= Owner.Value.Name and hit.Name~= "Blast" and hit.Name~= "Damage" and hit.ClassName~= ("Accessory")and hit.Parent:WaitForChild("LogiaImmune").Value =="Smoke" then humanoid = hit.Parent:findFirstChild("Humanoid") local EffectTorso = game.ReplicatedStorage["Plume-PlumeParticle"]:Clone() EffectTorso.Parent = hit.Parent:FindFirstChild("Torso") local EffectLArm = game.ReplicatedStorage["Plume-PlumeParticle"]:Clone() EffectLArm.Parent = hit.Parent:FindFirstChild("Left Arm") local EffectRArm = game.ReplicatedStorage["Plume-PlumeParticle"]:Clone() EffectRArm.Parent = hit.Parent:FindFirstChild("Right Arm") local EffectLLeg = game.ReplicatedStorage["Plume-PlumeParticle"]:Clone() EffectLLeg.Parent = hit.Parent:FindFirstChild("Left Leg") local EfectRLeg = game.ReplicatedStorage["Plume-PlumeParticle"]:Clone() EfectRLeg.Parent = hit.Parent:FindFirstChild("Right Leg") game.Debris:AddItem(EffectTorso, 1) game.Debris:AddItem(EffectLArm, 1) game.Debris:AddItem(EffectRArm, 1) game.Debris:AddItem(EffectLLeg, 1) game.Debris:AddItem(EfectRLeg, 1) script:remove() end wait() end arrow.Touched:connect(onTouched) arrow.Touched:connect(SmokeHit) t, s = r.Stepped:wait() d = 1 + 0 - 1 while t < d do end wait(2) arrow.Parent:Remove()
The part where the error would be coming from is line 42.
Thanks for reading <3
You should put another if statement after line 42 where it looks for the value. It probably still reads the value part even though it failed the check if it was an accessory. Also, :Remove
and :remove
is deprecated, use :Destroy()
. :wait()
is deprecated, use :Wait()
. connect
is deprecated, use :Connect
.:service
is deprecated, use :GetService()
. You also never created the debris service, so do game:GetService('Debris')
. Also, please indent properly.
Edit:
:findFirstChild
is deprecated, use :FindFirstChild
.