I have this script for a loot crate that will give a random weapon if touched.
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 ar = game.ServerStorage.AR:Clone()
ar.Parent = game.Players[player].Backpack
elseif random > 50 and random < 100 then
local crossbow = game.ServerStorage.Crossbow:Clone()
crossbow.Parent = game.Players[player].Backpack
end
script.Parent:Destroy()
end)
The problem is, it didn't work. It says: "Touched is not a valid member of Part"
Please help, thank you! <3

3 comments
You've forgot a end after line 11.
He was using
elseifthoughMake sure script.Parent is a part