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

My simple proximityPrompt is still broken?

Asked by 2 years ago

I have made a proximity prompt script that should get the tool in your hand and drop it to a certain position of "ToolSpot" But I just can't get it working. I believe it is all correct however whenever i trigger the proximity prompt, nothing happens to the equipped tool.

Script:

local Part = script.Parent
local ToolSpot = script.Parent.Parent.ToolSpot

local function remove(otherPart)
    local humanoid = otherPart.Parent:FindFirstChild('Humanoid')
    local player = game.Players:FindFirstChild(otherPart.Parent.Name)
    if humanoid and player then
        local inHand = otherPart.Parent:FindFirstChildWhichIsA('Tool')
        if inHand then
            inHand.Parent = game.Workspace
            inHand.Handle.Position = ToolSpot.Position
        end
    end
end
Part.ProximityPrompt.Triggered:Connect(remove)

Any advice, help, etc is highly appreciated!! Thanks!

1 answer

Log in to vote
0
Answered by 2 years ago
local ToolSpot = script.Parent.Parent.ToolSpot
script.Parent.ProximityPrompt.Triggered:Connect(function(player)
    local tool=player.Character:FindFirstChildOfClass"Tool"
    if not tool then return end
    tool.Parent,tool.Handle.Position = workspace,ToolSpot.Position
end)
Ad

Answer this question