Script not working properly?

Beginner Scripter here, So my script isn’t working and I get an error called: expected assignment or function call. Can anyone help me?

Code:

script.Parent.Touched:connect(function(hit)
 if hit.Parent:FindFirstChild("Humanoid") then
  game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Visible = true
  game.Players.LocalPlayer.Character.Humanoid:UnequipTools()
 end
end)

script.Parent.TouchEnded:connect(function()
 game.Players.LocalPlayer.PlayerGui.ScreenGui.TextLabel.Visible = false
end)
if script.Parent.Touched then game.StarterPack.ClassicSword.SwordScript.Disabled
end
script.Parent.Touched:Connect(function(Touched)
end)

Can you tell which line it’s erroring on? And also after the TouchEnded line the code is just empty, you aren’t doing anything?

Pretty sure you’re having problem with this line, maybe? You do need to set the disabled value (true or false).

Line 12, the code is supposed to unequip the tool and disable the script on the tool when the part is touched.

when I use true or false it does nothing

Are you using a LocalScript or a ServerScript?

touched is an event it won’t return anything
if you want to disable the script when it’s touched do it after the event fires

also to disable the script you can do script.Disabled = true and you can’t access to StarterPack when the game is executing cause everything on starterpack will go to the Backpack after you run the game

Here’s a better code:

script.Parent.Touched:Connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) then
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        player.PlayerGui.ScreenGui.TextLabel.Visible = true
        hit.Parent:FindFirstChild("Humanoid"):UequipTools()
        -- player.Backpack.ClassicSword.SwordScript.Disabled = true
    end
end)

Also I just noticed you’re disabling the script which is inside the StarterPack not which is in the character/backpack. Also you don’t need to disable the script because there’s no point for it. But still if you need you can remove the comment from the code above.

Ok I realised you ran the function inside the function
your mistake - script.Parent.Touched:Connect(function(Touched)
correct one - script.Parent.Touched:Connect(Touched)

You’re welcome

That worked just had to change the script a bit.