so i made a character for the player(this is actually part two of my problems(i already asked how to pickup the tools))
so he can pickup tools and use them.
but when he picks them up and presses backspace it puts the tool into workspace but doesn’t destroy
the welds
script:
local Service = game:GetService("UserInputService")--Variables
local Character = game.Players.LocalPlayer.Character
Service.InputBegan:Connect(function(obj,bool)--Input
local tool = game.Players.LocalPlayer.Character:FindFirstChildWhichIsA("Tool")--Variable
if obj.KeyCode == Enum.KeyCode.Backspace and tool then--When Pressing BackSpace
print("If Statement Started")--Prints So i Can Check Where It Broke
tool.Handle.CanTouch = false--Cantouch to false so it wouldn't make any welds
Character.RightArm:FindFirstChildWhichIsA("Weld"):Destroy()--destroys the weld (supposed to but doesn't work)
print("Weld Destroyed")--it never prints this meaning that it never comes to the rest of the script
tool.Handle.Position = Character.PrimaryPart.Position + Vector3.new(4,4,0)
print("if statement ended")
wait(2)
tool.Parent = workspace--for some reason it still does this though
tool.Handle.CanTouch = true
end
end)
this is the script that i use for picking up stuff
local Slime = game.Players.LocalPlayer.Character
local function OnTouched(hit)
if hit.Parent:FindFirstChild("Humanoid") then return end
if hit.Parent:IsA("Tool") and hit.Name == "Handle" then
if hit.Parent.Parent == Slime then--Checks if it's already inside the character so it doesn't make infinite welds
print("Already In Inventory!")
else
hit.Parent.Parent = Slime
local Weld = Instance.new("Weld")
Weld.Parent = Slime.RightArm
Weld.Part0 = Slime.RightArm
Weld.Part1 = hit
end
end
end
Slime.Humanoid.Touched:Connect(OnTouched)
please help me im getting very annoyed since tools are a big part of my game and if they completely break then there is really nothing to do.