#Proximity Prompt - Need someone to Explain to me

1 messages · Page 1 of 1 (latest)

loud halo
#

I really want Human interaction to learn Lua more, My goal is simple I just want to know how to interact with a Proximity Prompt where it is on another player who is in danger and another player can use that to save them.
please no AI I really want Human intervention only then I can learn
If you didnt understand what I am asking, please do ask me

#
local RunService = game:GetService("RunService")
local prompt = script.Parent
local playersHealing = {}

RunService.Stepped:Connect(function(_currentTime, deltaTime)
    for player, _value in pairs(playersHealing) do
        local humanoid = player.Character:FindFirstChildWhichIsA("Humanoid")
        if humanoid then
            humanoid.Health = humanoid.Health + 30 * deltaTime
        end
    end
end)

prompt.Triggered:Connect(function(player)
    playersHealing[player] = true
end)


prompt.TriggerEnded:Connect(function(player)
    playersHealing[player] = nil
end)

This is what I found on the document

#

so if I wanted to do it my way
where I just want to print a Message that the prompt has been interacted by a player

prompt.Triggered:Connect(function(player)
    print(player.Name .. " is saving")
end)
#

there is like 2 seconds of holding down the key so do I need a Debounce?
and is it possible to hide the prompt on client? or since I am making a save function do I just disable it on server side?
will disabling stop the code from running?

mellow topazBOT
#

studio** You are now Level 3! **studio

loud halo
#

I am dumb but I really want to talk on this and expand more.

clever forum
#

you are a robot 100%

unreal stump
#

so they can't save themselves.

loud halo
loud halo
#
prompt.Triggered:Connect(function(triggeringPlayer)
    print(triggeringPlayer.Name .. " rescued " .. char.Name)
    -- need to add simple tp the player that is saved to the player that is saving
end)

Ok so the above it the trigger and I put it into a function created the ProxiPrompt and sticked it to the player HRP

#

so I amassuming it waits until the player is interacting with the prompt?

#

I dont need a for or while loop for this one right?

#

Ok good news I managed to reach a point where I am creating the Rescue or save prompt on the player when they are drowning

#

and also made sure the local side is clear so they cant save themselves

#

Only thing is that the tigger is in Rescue and I need it to affect some functions in floorLava
I could use bindableEvents i think

#

Will get back to this tomorrow

#
function Rescue.Setup(char)
    print("Keep checking for new ProximityPrompts linked to HumanoidRootPart.")
    local hrp = char:WaitForChild("HumanoidRootPart") or nil
    if not hrp then
        return warn("HRP not found for ProximityPrompt")
    end
    
    -- creating a prompt on the player
    local rescuePrompt = Instance.new("ProximityPrompt")
    rescuePrompt.Name = "RescuePrompt"
    rescuePrompt.ActionText = "Rescue"
    rescuePrompt.ObjectText = char.Name
    rescuePrompt.HoldDuration = 2
    rescuePrompt.MaxActivationDistance = 5
    rescuePrompt.Parent = hrp

    -- tagging the prompt with the playerID so we can hide it on the player that needs the saving
    local player = game.Players:GetPlayerFromCharacter(char)
    if player then
        rescuePrompt:SetAttribute("OwnerUserId", player.UserId)
    else
        rescuePrompt:Destroy()
        return warn("No player found for ProximityPrompt")
    end

    rescuePrompt.Triggered:Connect(function(triggeringPlayer)
        print(triggeringPlayer.Name .. " rescued " .. char.Name)
        -- need to add simple tp the player that is saved to the player that is saving
    end)
end
#

here is what I got

#

ok gnite

#

will be back and until I learn how this work we working on this

#

This is also my only motivation

loud halo
#

Good Morning

#

I have done soem more Progress and did a little change to have an Attribute to do the check if the player needs saving

#

so on new player join or respawn we put an Attribute called Saved set to True

#

and I am using this Attribute to disable the stuff and move the player to the rescuer position

#

for now that's all I got working

#

I still need to know more about Custom Prompt idk how to do that and I want to learn it

#

What is this?

loud halo
#

Guys I have good news, I think I did it and made it work

#

in the most simplest way

#

the code gets complex cause of other stuff but I did it