math.randomseed(tick()) script.Parent.Touched:connect(function(hit) script.Disabled = true local player = hit.Parent.Name local random = math.random(1,100) if random > 0 and random < 50 then local sword1 = game.ServerStorage.Sword1:Clone() sword1.Parent = game.Players[player].Backpack elseif random > 50 and random < 100 then local sword2 = game.ServerStorage.Sword2:Clone() sword2.Parent = game.Players[player].Backpack end script.Parent:Destroy() end)
****Error Line 15 and 11
If the first thing that hits your script.Parent is not a player your script will break in some way. What you need to do is put in an if statement that checks to see if it is a player hitting your part or whatever it is like so:
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then -- code here end end)
Hope this helps. Have a good day scripting.