the script below that i am gonna show you is a script where it creates a proximity prompt in the player’s torso (yes the avatar type is set to r6) the player who triggers the prompt plays an animation and the other player dies but all of it doesn’t work !
plr = game.Players.PlayerAdded:Wait()
char = plr.CharacterAdded:Wait()
torso = char:WaitForChild("Torso")
hum = char:WaitForChild("Humanoid")
local prox = Instance.new("ProximityPrompt", torso)
prox.ActionText = "Womp Womp"
prox.ObjectText = "Womp Womp Him Until He Dies !"
prox.Triggered:Connect(function(t)
local anim = hum:LoadAnimation(script.Animation)
anim:Play()
wait(1)
t.Character.Humanoid.Health = 0
end)
1 Like
You shouldn’t do this, what exactly are you trying to achieve and where is the script located?
startergui its a local script im trying to create a proximity prompt in other player torso and if the prompt is triggered it plays animation and the player whose prompt is triggered dies :o
From what I can understand, you are trying to make a proximity prompt (inside the player), which kills the player if another player interacts with it.
You need to disable the prompt locally. (locally means for the player, but not for the other players)
Once you do this, use a server script, check for prompt triggers and perform tasks.
kills other player and the triggerer plays an animation
Firstly, if you want to kill a player then you wouldn’t do it in a localscript as the player will only be dead for the person who triggered the prompt.
Secondly, to add the prompt to every player you would have to do something like this:
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(t)
local anim = hum:LoadAnimation(script.Animation)
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
1 Like
--// Local Script
local Players = game:GetService("Players");
local Player = Players.LocalPlayer;
local ProximityPrompt: ProximityPrompt;
ProximityPrompt = Torso:FindFirstChild("Prompt"); --// find the prompt
if (ProximityPrompt) then
ProximityPrompt.Enabled = false; --// Disables the prompt for the local player
end;
1 Like
but how to make the player unable to trigger prompt to himself only others can trigger the prompt in the player same thing with player
@RedOver133 read this, You can also fire a remote event with the prompt as the parameter to disable it.
--// local script
RemoteEvent.OnClientEvent:Connect(function(prompt: ProximityPrompt): ()
prompt.Enabled = false;
end);
2 Likes
To make it so you can’t trigger a prompt you would do prox.Enabled = false
If you do it server side then the prompt would be disabled everywhere so another thing you can do is create a localscript in StarterCharacterScripts
with this code:
local Character = script.Parent
Character.DescendantAdded:Connect(function(Desc)
if Desc:IsA("ProximityPrompt") then
Desc.Enabled = false
end
end)
1 Like
where i put it? starter gui or??
Anywhere, as long as its in StarterPlayerScripts
, StarterCharacterScripts
, StarterGui
, and StarterPack
.
sorry to inform you but it doesn’t function but im trying to say is the player can’t womp womp himself (the action of prompt)
The code which @sickbadassdragon provided basically disables any prompt which gets added to the player character automatically. (to make sure that the local player cant kill himself by triggering the prompt)
Other players can still activated the prompt, the local player can’t.
Should be added to a LocalScript
in a place like StarterGui
but they all don’t work idk why i created remote event in replicated storage and made a variable about it so i don’t get any errors but nothing works idk why :c
you can ignore that, use the code which he provided.
i used al his one works the next ones dont
and fyi i rlly apreciate y’all’s effort and help
What next ones? You need to elaborate a bit more so we could help you better