I am making a game in which you have to escape each level by picking up, throwing and dropping parts.
My middle click (throwing) function isn't working. The part isn't moving at all, and I'm not sure if the click is registering. Am I using the input wrong? Please help.
Oh, and here's the code.
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local uis = game:GetService("UserInputService") local pack = player:WaitForChild("Backpack") local character = player.Character mouse.Icon = "rbxassetid://3248591495" mouse.Button1Down:Connect(function() if mouse.Target ~= nil then if mouse.Target.Locked == false then mouse.Target.Name = "Handle" local tool = Instance.new("Tool", pack) tool.CanBeDropped = false tool.TextureId = "rbxassetid://3248571585" mouse.Target.Parent = tool end end end) mouse.Button2Down:Connect(function() if character.Tool ~= nil then character.Tool.Handle.CanCollide = true character.Tool.Handle.Position = mouse.Hit.p character.Tool.Handle.Parent = workspace character.Tool:Destroy() end end) if uis:IsMouseButtonPressed(Enum.UserInputType.MouseButton3) == true then if character.Tool ~= nil then character.Tool.Handle.CanCollide = true character.Tool.Handle.Parent = workspace character.Tool.Handle.CFrame = CFrame.new(character.Tool.Handle.Position, mouse.Hit.p) character.Tool.Handle.Velocity = character.Tool.Handle.CFrame.LookVector * 5 character.Tool:Destroy() end end uis.InputBegan:Connect(function(input, processed) if input.KeyCode == Enum.KeyCode.ButtonR2 then if mouse.Target ~= nil then if mouse.Target.Locked == false then mouse.Target.Name = "Handle" local tool = Instance.new("Tool", pack) tool.CanBeDropped = false tool.TextureId = "rbxassetid://3248571585" mouse.Target.Parent = tool end end end if input.KeyCode == Enum.KeyCode.ButtonL2 then if character.Tool ~= nil then character.Tool.Handle.CanCollide = true character.Tool.Handle.Position = mouse.Hit.p character.Tool.Handle.Parent = workspace character.Tool:Destroy() end end end)
IM Not In The Mood To Do It For You, its better if you practice by MAKING the script yourself. But If you use bodygyros or the body velocities or whatever, you can change the numbers so when you clone it into your item, it look liek you threw it. Now, for the middle click thing. I know the command for letters and maybe middle, its one of them. But if you put this code into a localscript into starterpack, you can detect this then activate a remote event that you should put in replicated storage, then in workspace a script that detects when its fired. (local script in starterpack)
UIS = game:GetService("UserInputService") UIS.InputBegan:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.Q then game.ReplicatedStorage.[name of remote event]:FireServer() end end) --reason its in localscript is so only player that this script is in is detected and no one else on the server can click q or middle button whatever then something happens to you or all players
(workspace normal scipt)
game.ReplicatedStorage.[Name of Remote Event].OnServerEvent:Connect(function() instance.new("bodyVelocity",item) whatever end
Your Way Doesnt Work Because I dont know why, GetMouse works but i just, i feel dumb