I want this script to check if you have PVP enabled, if you do, it will give you a message, but it shows the error “Attempted to index nil with _pvp.”
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
if plr._pvp.Value == false then
for i = 1,20 do
plr.PlayerGui.Alert.Status.TextTransparency =plr.PlayerGui.Alert.Status.TextTransparency + .1
end
end
end)```
This is unreliable code. The touched function will operate if whatever part touches ANYTHING. Therefore you need to actually ensure what it’s touching is a player first off. If it is touching the floor, stuff in it, or other things of sort, there isn’t a player associated to that so it will of course return nil.