So far I have this script: plr = game.Players.LocalPlayer mouse = plr:GetMouse()
function woosh() if mouse.Target ~= nil then if mouse.Target.CanCollide== false and mouse.Target.Transparency == .5 then mouse.Target.CanCollide= true mouse.Target.Transparency = 0 else mouse.Target.Transparency = .5 mouse.Target.CanCollide = false end end end
mouse.Button1Down:connect(woosh)
How would I make it so that instead of clicking, you hover over the part with your mouse and press k to do this function?
Easy.
plr = game.Players.LocalPlayer mouse = plr:GetMouse() function woosh() if mouse.Target ~= nil then if mouse.Target.CanCollide== false and mouse.Target.Transparency == .5 then mouse.Target.CanCollide= true mouse.Target.Transparency = 0 else mouse.Target.Transparency = .5 mouse.Target.CanCollide = false end end end game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if inputObject.KeyCode == Enum.KeyCode.R then woosh() end end)
Here ya go, should work.
The way wild man is doing it is only on the client's side, so I changed his a little bit. Add a local script in StarterGui. In it add this code :
plr = game.Players.LocalPlayer mouse = plr:GetMouse() game:GetService("UserInputService").InputBegan:connect(function(inputObject, gameProcessedEvent) if not gameProcessedEvent then if inputObject.KeyCode == Enum.KeyCode.K then workspace.CollisionOff:FireServer(mouse.Target) if mouse.Target:IsA("BasePart") then mouse.Target.CanCollide = false elseif mouse.Target:IsA("Model") then for i, v in pairs(mouse.Target:GetDescendants()) do if v then if v:IsA("BasePart") then v.CanCollide = false end end end end end end end)
Then add a remote event in workspace. Call it "CollisionOff" Add this script in it.
script.Parent.OnServerEvent:Connect(function(target) if target:IsA("BasePart") then target.CanCollide = false elseif target:IsA("Model") then for i, v in pairs(target:GetDescendants()) do if v then if v:IsA("BasePart") then v.CanCollide = false end end end end end)