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

I need to make a tool be picked up with E and stay there?

Asked by 3 years ago

I was making a Homestore and I know I can put the try on tool in starter pack but I was making it so you pick it up with "E" (so it looks better) And I made the script and everything works but It removes the try-on tool so only one person can get it is there a way I can make it stay there this is my pickup script

local re = Instance.new("RemoteEvent") re.Parent = game:GetService("ReplicatedStorage") re.Name = "toolEvent"

re.OnServerEvent:Connect(function(plr, tool) local mag = (tool:WaitForChild("Handle").Position - plr.Character.HumanoidRootPart.Position).magnitude

if mag < 5 then
    tool.Parent = plr.Backpack
end

end)

function untouch(list) for i = 1, #list do local handle = list[i]:WaitForChild("Handle") if handle then local ti = handle:FindFirstChild("antiTouch") -- < if not ti then local clone = script.antiTouch:Clone() -- < clone.Parent = handle clone.Disabled = false end end end end

local tools = workspace:WaitForChild("tools"):GetChildren() untouch(tools)

workspace.tools.ChildAdded:Connect(function(child) untouch({child}) end)

workspace.ChildAdded:Connect(function(child) if child:IsA("Tool") then wait() child.Parent = workspace.tools end end)

Answer this question