I don't know how to prevent everyone from being revived. I just only wanted that person who is getting affected to be affected.
https://www.youtube.com/watch?v=z8dopZLAB04 - Video on the problem
local ProximityPromptService = game:GetService("ProximityPromptService") local DownedHumanoidRootPart = script.Parent.Parent local Character = DownedHumanoidRootPart.Parent local Revived = Character.Humanoid:LoadAnimation(script.Revived) local Debries = game:GetService("Debris") local ServerStorage = game.ServerStorage local Reviving local SoundClone local GotRevived local function onPromptHoldBegan(_, player) Reviving = player.Character:WaitForChild("Humanoid"):LoadAnimation(script.RevivingPlayer) if player.Character.Status.IsDowned.Value == false then player.Character:WaitForChild("Humanoid").WalkSpeed -= 16 player.Character:WaitForChild("Humanoid").JumpPower -= 50 player.Character:WaitForChild("Status"):WaitForChild("IsReviving").Value = true Reviving:Play() SoundClone = ServerStorage:WaitForChild("Downed"):WaitForChild("VoiceLines"):WaitForChild("RevivingPlayer"):WaitForChild("Reviving"..math.random(1,8)):Clone() SoundClone.Parent = DownedHumanoidRootPart SoundClone:Play() -- Model weld code (doing this to save space) Stim:WaitForChild("Grip"):WaitForChild("ReviveSound"):Play() Character.Status.BeingRevived.Value = true DownedHumanoidRootPart:WaitForChild("ReviveIcon"):WaitForChild("ImageLabel").ImageColor3 = Color3.new(255, 255, 255) end end
Easy fix, just check if the player has the right name.
local ProximityPromptService = game:GetService("ProximityPromptService") local DownedHumanoidRootPart = script.Parent.Parent local Character = DownedHumanoidRootPart.Parent local Revived = Character.Humanoid:LoadAnimation(script.Revived) local Debries = game:GetService("Debris") local ServerStorage = game.ServerStorage local Reviving local SoundClone local GotRevived local function onPromptHoldBegan(_, player) if Character.Name = "" then -- insert name of the specific player you only want to be revived Reviving = player.Character:WaitForChild("Humanoid"):LoadAnimation(script.RevivingPlayer) if player.Character.Status.IsDowned.Value == false then player.Character:WaitForChild("Humanoid").WalkSpeed -= 16 player.Character:WaitForChild("Humanoid").JumpPower -= 50 player.Character:WaitForChild("Status"):WaitForChild("IsReviving").Value = true Reviving:Play() SoundClone = ServerStorage:WaitForChild("Downed"):WaitForChild("VoiceLines"):WaitForChild("RevivingPlayer"):WaitForChild("Reviving"..math.random(1,8)):Clone() SoundClone.Parent = DownedHumanoidRootPart SoundClone:Play() -- Model weld code (doing this to save space) Stim:WaitForChild("Grip"):WaitForChild("ReviveSound"):Play() Character.Status.BeingRevived.Value = true DownedHumanoidRootPart:WaitForChild("ReviveIcon"):WaitForChild("ImageLabel").ImageColor3 = Color3.new(255, 255, 255) end end end
You haven't shown us your entire script (nothing in your script actually revives any player) but some notes:
Reviving
should either be local or per-player (otherwise if 2 people try to revive the same person you'll be trying to remember two animations in one variable - one of them will be overwritten). If the animation ends on its own then you can just make it local.SoundClone
is the same way. If you need to access it again, you have two options:
:FindFirstChild("ReviveSound")
Character.Status.BeingRevived.Value = true
in onPromptHoldBegan
. Do you set it to false in onPromptHoldEnd
if it didn't complete?BeingRevived.Value == true
? If so, this is a problem, because this means that your script is willing to:
Less important notes about SoundClone = ServerStorage:WaitForChild("Downed"):WaitForChild("VoiceLines"):WaitForChild("RevivingPlayer"):WaitForChild("Reviving"..math.random(1,8)):Clone()
:
WaitForChild
when accessing things that are in the game from the beginning (this does not include anything that is cloned by a script or by Roblox, such as guis that are cloned from StarterGui, but does include probably everything in ServerStorage, unless you clone stuff in there after the game starts)local RevivingSounds = ServerStorage.Downed.VoiceLines.RevivingPlayer:GetChildren() -- this can go near the top SoundClone = RevivingSounds[math.random(1, #RevivingSounds)] -- this replaces the current SoundClone = line