Hello, I am currently learning how to use proximity prompts and I set up a proximity prompt to show up for everyone but he person with low health. I was wondering How to make the prompt only show up for the person who is hurt, when I set this script up it still shows for both players and I keep getting a error called Animator.EvaluationThrottled
local
local char = script.Parent
local humanoid = char.Humanoid
local rep = game:GetService("ReplicatedStorage")
local StaggerEvent = rep.FInisherEvents:WaitForChild("Stagger")
local SeeEvent = rep.FInisherEvents:WaitForChild("No see")
local cooldown = false
humanoid.HealthChanged:Connect(function(health)
if health <= 50 and cooldown == false then
wait(0.7)
StaggerEvent:FireServer(char)
wait(0.7)
cooldown = true
wait(10)
cooldown = false
elseif health > 50 then return end
end)
SeeEvent.OnClientEvent:Connect(function(char)
print("hello")
wait()
local car = script.Parent
print(car)
local prompt = car.Torso:FindFirstChild("Finisher")
prompt.Enabled = false
end)
server
local rep = game:GetService("ReplicatedStorage")
local StaggerEvent = rep.FInisherEvents:WaitForChild("Stagger")
local serverstorage = game:GetService("ServerStorage")
local Assests = serverstorage["Finishing move stuff"]
local SeeEvent = rep.FInisherEvents:WaitForChild("No see")
StaggerEvent.OnServerEvent:Connect(function(player)
print(player)
local Prompt = Assests:FindFirstChild("Finisher")
Prompt.Enabled = false
local prompt2 = Prompt:Clone()
prompt2.Enabled = false
prompt2.Parent = player.Character:FindFirstChild("Torso")
prompt2.Enabled = true
SeeEvent:FireClient(player)
end)
Hi, is it possible you could do something like this in a local script?
humanoid.HealthChanged:Connect(function(health)
if health --[[conditions here]] then
prompt.Enabled = true
else
prompt.Enabled = false
end
end)
It checks when the humanoid health changed and according to the condition you put it enables the prompt for them and only them (because local script) if the condition is met.
I would normally do that but I have it set up to where the prompt gets cloned and the cloned gets put in the other players torso for anyone but that player to see
If you want the player thats low health to NOT see the prompt, you can do the opposite of the code
humanoid.HealthChanged:Connect(function(health)
if health --[[conditions here]] then
prompt.Enabled = false
else
prompt.Enabled = true --this may be useless because we dont need to see a prompt thats meant for others
end
end)
or you could check for a prompt in the players torso everytime a new instance is added and disable it (again in a localscript, and i recommend this script more because its just easier to handle)
game.Players.LocalPlayer.Character.Torso.ChildAdded:Connect(function(instance)
if instance:IsA("ProximityPrompt") then
instance.Enabled = false
end
end)
Okay so I kinda figured out my problem which was I didnt add a proper cooldown so it would make 2 instances of the prox prompt which would disable one but not the other I fixed that but my next thing is when creating a script to involve who uses the prox prompt I would make it a local script and it would be in the prox prompt right? I wanna do something like this next:
local prompt = script.Parent
prompt.Triggered:Connect(function(player)
--code
end)
you don’t have to make a local script to find out who’s using the proximity prompt, when you make the event prompt.Triggered:Connect(function(player) it already tells you which player interacted with it and you even typed it out (inside the parameter)
For example,
prompt.Triggered:Connect(function(player)
print(player.Name…” interacted with me!”)
—If I interacted with that it would say IndeedMythical interacted with me!
end)
(Im on mobile right now so I can’t format stuff properly)
And by the way, local scripts can’t run in workspace so nothing would happen if you try to interact with the prompt with a local script