so basically im trying to make a part where if you touch it your head explodes. it works in studio solo test, but when i join in game, it says" Workspace.die.Script:6: attempt to index field 'LocalPlayer' (a nil value)" it's a regular script, not a localscript, if that helps.
keep in mind im a beginner beginner
local die = script.Parent
debounce = false
script.Parent.Touched:Connect(function(hit)
local p = game.Players.LocalPlayer.Character
if hit.Parent:FindFirstChild("Head") and debounce == false then
debounce = true
local b = Instance.new("Explosion")
b.BlastPressure = 1
b.BlastRadius = 1
b.Position = p.Head.Position
b.Parent = game.Workspace
p.Head:Remove()
debounce = false
print("worked")
end
end)

4 comments
fixed the couldnt remove head
removed debounce to make the script work more than once
I replied on a different account under the name "MrSmenry" on my answer. Hopefully that explains why it was erroring.
Do you have FE on? If so, test your game through the 'start' button which has an icon that looks like a server.