local player=game:GetService("Players").LocalPlayer
local char=player.Character or player.CharacterAdded:Wait()
local h=char:WaitForChild("HumanoidRootPart")
script.Parent.Touched:Connect(function(hit)
local explosion=Instance.new("Explosion",workspace)
explosion.Position=Vector3.new(h.Position)
end)
why did u used Local Player in script? it should be script and u should add
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChildWhichIsA("Humanoid") then
local explosion=Instance.new("Explosion",workspace)
explosion.Position=Vector3.new(h.Position)
end
end)
You should put it in StarterCharacter and detect if any of the character parts is touching that part by using Humanoid.Touched event and checking it from there.
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChildWhichIsA("Humanoid") then
local explosion=Instance.new("Explosion",workspace)
explosion.Position= hit.Position
end
end)
that will work Put it in script and the script into the part that u want to explode