local function CreatePrompt(Character)
local torso = Character:WaitForChild(“Torso”)
local hum = Character:WaitForChild(“Humanoid”)
local prox = Instance.new(“ProximityPrompt”, torso)
prox.ActionText = “Womp Womp”
prox.ObjectText = “Womp Womp Him Until He Dies !”
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
CreatePrompt(Character)
end)
end)
for _, Player in ipairs(game.Players:GetPlayers()) do
local Character = Player.Character or Player.CharacterAdded:Wait()
CreatePrompt(Character)
Player.CharacterAdded:Connect(CreatePrompt)
end
Create a new LocalScript inside StarterCharacterScripts
Paste this code:
local Character = script.Parent
Character.DescendantAdded:Connect(function(Desc)
if Desc:IsA("ProximityPrompt") then
Desc.Enabled = false
end
end)
for _, Desc in ipairs(Character:GetDescendants()) do
if Desc:IsA("ProximityPrompt") then
Desc.Enabled = false
end
end
I made a small error in my previous script, here is the updated one:
Now the animation should be loaded as soon as the character is created, and then played when the prompt is triggered.
local function CreatePrompt(Character)
local torso = Character:WaitForChild("Torso")
local hum = Character:WaitForChild("Humanoid")
local prox = Instance.new("ProximityPrompt", torso)
prox.ActionText = "Womp Womp"
prox.ObjectText = "Womp Womp Him Until He Dies !"
local anim = hum:LoadAnimation(script.Animation)
prox.Triggered:Connect(function(t)
anim:Play()
wait(1)
t.Character.Humanoid.Health = 0
end)
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
CreatePrompt(Character)
end)
end)
for _, Player in ipairs(game.Players:GetPlayers()) do
local Character = Player.Character or Player.CharacterAdded:Wait()
CreatePrompt(Character)
Player.CharacterAdded:Connect(CreatePrompt)
end
local LoadedAnimations = {}
local function CreatePrompt(Character)
local torso = Character:WaitForChild("Torso")
local hum = Character:WaitForChild("Humanoid")
local prox = Instance.new("ProximityPrompt", torso)
prox.ActionText = "Womp Womp"
prox.ObjectText = "Womp Womp Him Until He Dies !"
LoadedAnimations[Character] = hum:LoadAnimation(script.Animation)
prox.Triggered:Connect(function(PlayerWhoTriggered)
if LoadedAnimations[PlayerWhoTriggered.Character] then
LoadedAnimations[PlayerWhoTriggered.Character]:Play()
end
wait(1)
PlayerWhoTriggered.Character.Humanoid.Health = 0
end)
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
CreatePrompt(Character)
end)
end)
for _, Player in ipairs(game.Players:GetPlayers()) do
local Character = Player.Character or Player.CharacterAdded:Wait()
CreatePrompt(Character)
Player.CharacterAdded:Connect(CreatePrompt)
end
local LoadedAnimations = {}
local function CreatePrompt(Character)
local torso = Character:WaitForChild("Torso")
local hum = Character:WaitForChild("Humanoid")
local prox = Instance.new("ProximityPrompt", torso)
prox.ActionText = "Womp Womp"
prox.ObjectText = "Womp Womp Him Until He Dies !"
prox.Triggered:Connect(function(PlayerWhoTriggered)
local Animation = LoadedAnimations[PlayerWhoTriggered];
if (not Animation) then
LoadedAnimations[PlayerWhoTriggered] = PlayerWhoTriggered.Character.Humanoid:LoadAnimation(script.Animation) --// bad practice, avoid at all costs
Animation = LoadedAnimations[PlayerWhoTriggered];
end
Animation:Play();
task.wait(1)
hum.Health = 0
end)
end
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
CreatePrompt(Character)
end)
end)
for _, Player in ipairs(game.Players:GetPlayers()) do
local Character = Player.Character or Player.CharacterAdded:Wait()
CreatePrompt(Character)
Player.CharacterAdded:Connect(CreatePrompt)
end