Hello! I tried making this script that clones a PromixityPrompt when health is low inside the head of a character, yet when I test it, it won't appear to me but only to the player with low health.

Here are the scripts, please help...

LocalScript in StarterPlayerScripts.

local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
repeat wait() until char:FindFirstChild("Humanoid")
local humanoid = char.Humanoid
local walkspeed = tonumber(humanoid.WalkSpeed)

local db = false

humanoid.HealthChanged:Connect(function()
  if db == false then
    if humanoid.Health <= 150 then
        db = true
            game.ReplicatedStorage.RemoteEvents.Draining:FireServer(plr)
        --end
    end
 else 
    if humanoid.Health >= 150 then
        db = false
        game.ReplicatedStorage.RemoteEvents.DrainingSTOP:FireServer(plr)
    end
 end
end)

ServerScript in StarterCharacterScripts.

game.ReplicatedStorage.RemoteEvents.Draining.OnServerEvent:Connect(function(plr)
    local x = script.Drain:Clone()
    x.Parent = plr.Character.Head
    x.Enabled = true
    plr.Character.Humanoid.WalkSpeed = 0

    game.ReplicatedStorage.RemoteEvents.DrainingSTOP.OnServerEvent:Connect(function()
        x:Destroy()
        plr.Character.Humanoid.WalkSpeed = 16
    end)
end)

3 comments

0

Have you tried using a server script? (Regular script)

0

@2_MMZ Using a server script would make the RemoteEvent fire on client, which is not what I need since the ProximityPrompt needs to be visible by the whole server!

0

Have you tried firing all clients and inserting the ProximityPrompt into the damaged character?