Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make proximity prompt shows its own tool name?

Asked by
TechModel 118
2 years ago
Edited 2 years ago

This script is located in the ServerScriptService and I have all of these variety of tools, guns etc.

I want the ObjectName to be unique and give individual tools showing their own name, but every other tool says "Tool" as the object name.

So in conclusion, how do I make it so it shows it's own name? I forgot and I don't know what it's really called for it.

local pps = game:GetService("ProximityPromptService")


local distance = 5
local timeToHold = 0


pps.PromptTriggered:Connect(function(pp, plr)

    local tool = pp.Parent.Parent
    if tool:IsA("Tool") then

        tool.Parent = plr.Backpack

        pp:Destroy()
    end
end)


while wait() do


    for i, descendant in pairs(workspace:GetDescendants()) do

        if descendant:IsA("Tool") and descendant:FindFirstChild("Handle") and not game.Players:GetPlayerFromCharacter(descendant.Parent) then


            if descendant.Handle:FindFirstChild("TouchInterest") then descendant.Handle.TouchInterest:Destroy() end


            local pp = descendant.Handle:FindFirstChild("ProximityPrompt")

            if not pp then

                pp = Instance.new("ProximityPrompt")
                pp.MaxActivationDistance = distance
                pp.HoldDuration = timeToHold
                pp.RequiresLineOfSight = false
                pp.ObjectText = "Tool"
                pp.ActionText = "Pick Up"

                pp.Parent = descendant.Handle
            end
        end
    end
end

It has something to do with line 39 "pp.ObjectText = "Tool"" but in the quotation marks, I forgot how to put the tool name that is being picked up.

1 answer

Log in to vote
1
Answered by 2 years ago

try doing

pp.ObjectText = Tool.Name
0
I did, but the "Tool TechModel 118 — 2y
0
You dont put "" around Tool.Name. JustinWe12 723 — 2y
0
Since Tool.Name returns a string, you don't need to put "" around it Mathilinium 112 — 2y
0
Sorry for the really late reply! Firgured it out that if I added Local Tool = descendant then it works fine TechModel 118 — 2y
Ad

Answer this question