Problem with deleting parts

I have problem with my script. When player reset it doesn’t work. If I use another proximity prompt it shows me that the object from another prompt is not child of workspace and humanoid.Died function is not working.

Local Script:

local gui = script.Parent
local plr = game.Players.LocalPlayer
local hum = plr.Character:WaitForChild("Humanoid")
local event = game:GetService("ReplicatedStorage"):WaitForChild("EggGivingEvent")
local leaderstats = plr:WaitForChild("leaderstats"):WaitForChild("hiddenfolder"):WaitForChild("Eggs")

game.Workspace.EasterEgg1.ProximityPrompt.Triggered:Connect(function()
	event:FireServer()
	game.Workspace.EasterEgg1:Destroy()
end)

game.Workspace.EasterEgg2.ProximityPrompt.Triggered:Connect(function()
	event:FireServer()
	game.Workspace.EasterEgg2:Destroy()
end)

game.Workspace.EasterEgg3.ProximityPrompt.Triggered:Connect(function()
	event:FireServer()
	game.Workspace.EasterEgg3:Destroy()
end)

game.Workspace.EasterEgg4.ProximityPrompt.Triggered:Connect(function()
	event:FireServer()
	game.Workspace.EasterEgg4:Destroy()
end)

game.Workspace.EasterEgg5.ProximityPrompt.Triggered:Connect(function()
	event:FireServer()
	game.Workspace.EasterEgg5:Destroy()
end)

game.Workspace.EasterEgg6.ProximityPrompt.Triggered:Connect(function()
	event:FireServer()
	game.Workspace.EasterEgg6:Destroy()
end)

leaderstats:GetPropertyChangedSignal("Value"):Connect(function()
	gui.Text = leaderstats.Value
end)
hum.Died:Connect(function()
	wait()
	gui.Text = leaderstats.Value
end)

Please fast reply for this problem.

Three things;

  1. Please be descriptive in your title
  2. Send us the error
  3. Where is this Localscript located, Starterplayerscript, Startercharacterscripts or somewhere else (list it)?
1 Like

the script it located in gui where it shows itself value in text. game.startergui.Parent.Parent.Parent.Parent.Parent

Well the error usually means that it can’t find the object are you sure you put the egg in the workspace/it’s actually in the correct spot like not in something like a folder or model, try adding a task.wait with enough time at the start at the script incase you are loading in a part and its not automatically in the game

It is located in workspace but still doesnt work.

you could use WaitForChild instead

example

workspace:WaitForChild("EasterEgg1").ProximityPrompt.Triggered:Connect(function()
	event:FireServer()
	workspace.EasterEgg1:Destroy()
end)

And for the humanoid not working add player.CharacterAdded:Wait() before it finds the humanoid

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.