Hello, as the title says, I need to make tool able to get picked up by interacting with ProximityPrompt, tool will be probably for one life and if person died with tool in inventory, as you know that tool was for one life, it will respawn in workspace again. How I could make it?
So you can’t get another one until you die?
You can get another one if you pick it up on the same place, even if you died, doesnt matter where probably
You can use this if you’d like (an old script I made similar)
It was for a weapon, but it’s a tool so it would work the same
local canGive = true
local Detect = script.Parent.Button.ProximityPrompt
Detect.Triggered:Connect(function(player)
local backpack = player.Backpack
local Weapon = game.ServerStorage.MCX -- Change to items name and location (recommended to keep the weapon in serverstorage)
-- Add more if needed
local weaponClone = Weapon:Clone()
for i, v in pairs(backpack:GetChildren()) do -- Searches the players backpack
if v.Name == "MCX" then -- Also change to items EXACT name
canGive = false -- If you have it then don't give you another one
end
end
if canGive then
weaponClone.Parent = backpack -- if you don't have it then it gives you one
end
canGive = true
end)
Local script or common script for this?
Server script
Also change local Detect = script.Parent.Button.ProximityPrompt
to your proximity prompt
local Detect = script.Parent.Button.GrabInteraction
good? (Script is in tool and GrabInteraction is name of proximityprompt.)
im not sure if this works because I never played around with proximity prompts, but try this in a local script
script.Parent.Triggered:Connect(function()
script.Parent.Enabled = false
-- give weapon here
repeat
wait()
until game.Players.LocalPlayer.Character.Died do
script.Parent.Enabled = true
end
end)
(dont ask me why I had that extra line at the end xd)
Yes, it should, though if the script is in the item local Weapon = game.ServerStorage.MCX
should be something like local Weapon = script.Parent.Parent
Item is in serverstorage, maybe I should put it in workspace however
Oh okay, either works, up to you
local Detect = script.Parent.Button.Grab
is on their’s place? (grab = proximity prompt)
nevermind it was not on their place
I guess I messed up with some parts in script, everything is assigned correctly but it doesnt work and theres some parts kinda missing, if person grabbed the tool, it should destroy and if died with tool in inventory, it will respawn again
Script:
local canGive = true
local Detect = script.Parent.PartBox.Grab
Detect.Triggered:Connect(function(player)
local backpack = player.Backpack
local Weapon = script.Parent.Parent -- Change to items name and location (recommended to keep the weapon in serverstorage)
-- Add more if needed
local weaponClone = Weapon:Clone()
for i, v in pairs(backpack:GetChildren()) do
if v.Name == "Box" then -- Also change to items EXACT name
canGive = false
end
end
if canGive then
weaponClone.Parent = backpack
end
canGive = true
end)
Explorer:
and yes when i touch tool it gets in my hands because of handle and proximityprompt still exists and i can interact while holding item bruh
proximity prompt is in PartBox
You could make the proximity prompt get destroyed once it is triggered.
script.parent.Triggered:Connect(function()
script.parent:Destroy()
end()
You could do this:
local proximityPrompt = script.Parent:WaitForChild("ProximityPrompt")
local serverStorage = game:GetService("ServerStorage")
proximityPrompt.Triggered:Connect(function(plr)
local tool = serverStorage:WaitForChild("Tool"):Clone()
tool.Parent = plr.Backpack
end)
change that to local Weapon = script.Parent