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

error message says a part isnt a part of the tool when its clearly is what is going on?

Asked by 3 years ago
Edited 3 years ago

so basically whenever I run the code I get the error message of BLADEPART1 is not a valid member of Tool "Players.MrAspuru.Backpack.Anakin's Lightsaber"

I don't understand this as it is clearly a part of the tool I don't know how to add images to this but BLADEPART1 is in the tool here is the script which is showing the error message the error message says it's from line 116



attacksequencenumber = 0 local enabled = true sound1 = game.Workspace.Sound11 sound2 = game.Workspace.Sound21 sound3 = game.Workspace.Sound31 sound4 = game.Workspace.Sound41 sound5 = game.Workspace.Sound51 tool = script.Parent damagecooldown = false local ReplicatedStorage = game:GetService("ReplicatedStorage") local remoteEvent = ReplicatedStorage:WaitForChild("Damage") local playerer = script.Parent.Parent on = true function damage(obj) local plr = obj.Parent:FindFirstChild("Humanoid") if plr then if script.Parent.BladeOn.Value == 1 then if enabled == false then if on == true then on = false remoteEvent:FireServer("Attack") wait(0.6) on = true end end end end end tool.Equipped:Connect(function() equipped = true end) tool.Unequipped:Connect(function() equipped = false end) script.Parent.Equipped:Connect(function(Mouse) Mouse.Button1Down:Connect(function() animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) animation2 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation2) animation3 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation3) animation4 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation4) animation5 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation5) if enabled == true then if script.Parent.BladeOn.Value == 1 then if attacksequencenumber == 0 then animation:Play() sound1:Play() end if attacksequencenumber == 1 then animation2:Play() sound2:Play() end if attacksequencenumber == 2 then animation3:Play() sound3:Play() end if attacksequencenumber == 3 then animation4:Play() sound4:Play() end if attacksequencenumber == 4 then animation5:Play() sound5:Play() end enabled = false attacksequencenumber = attacksequencenumber + 1 if attacksequencenumber == 5 then attacksequencenumber = 0 end wait(0.8) enabled = true end end end) end) script.Parent.Unequipped:Connect(function() animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) animation2 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation2) animation3 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation3) animation4 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation4) animation5 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation5) animation:Stop() animation2:Stop() animation3:Stop() animation4:Stop() animation5:Stop() end) local part = script.Parent.BLADEPART1 local player = game.Players.LocalPlayer local clashsound = game.Workspace.Clash local function onPartTouched(otherPart) print(part.Name .. " has touched " .. otherPart.Name) if otherPart.Name == "BLADEPART1" and otherPart.ClassName == "Part" then print("clash") animation:Stop() animation2:Stop() animation3:Stop() animation4:Stop() animation5:Stop() if script.Parent.BladeOn.Value == 1 then clashsound:Play() end end end part.Touched:Connect(onPartTouched) local player = game.Players.LocalPlayer local mouse = player:GetMouse() local held = false mouse.Button2Down:connect(function() if equipped == true then animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation) animation2 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation2) animation3 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation3) animation4 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation4) animation5 = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Animation5) Block = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent.Block) animation:Stop() animation2:Stop() animation3:Stop() animation4:Stop() animation5:Stop() held = true Block:Play() player.Character.Humanoid.WalkSpeed = 8 script.Parent.IsBlocking.Value = 1 if script.Parent.BladeOn.Value == 1 then sound2:Play() end end end) mouse.Button2Up:connect(function() held = false Block:Stop() player.Character.Humanoid.WalkSpeed = 16 script.Parent.IsBlocking.Value = 0 if equipped == true then if script.Parent.BladeOn.Value == 1 then sound2:Play() end end end) script.Parent.BLADEPART1.Touched:Connect(damage)

1 answer

Log in to vote
0
Answered by 3 years ago

I fixed it i just had to replace script.parent.BLADEPART1 with script.parent:WaitForChild("BLADEPART1")

Ad

Answer this question