If you can fix it thanks in advance
b.Position = Vector3.new(0,6000,0) -- (MouseLocation, Height of the Rock, MouseLocation)
local player = game.Players.LocalPlayer repeat wait() until player.Character.Humanoid local humanoid = player.Character.Humanoid local mouse = player:GetMouse() local b = Instance.new("Part") local anim = Instance.new("Animation") anim.AnimationId = "http://www.roblox.com/asset/?id=333356213" mouse.KeyDown:connect(function(key) if key == "v" then local playAnim = humanoid:LoadAnimation(anim) playAnim:Play() game:GetService("Chat"):Chat(game.Players.LocalPlayer.Character.Head,"text","Red") wait(1) game:GetService("Chat"):Chat(game.Players.LocalPlayer.Character.Head,"text","Red") wait(1) game:GetService("Chat"):Chat(game.Players.LocalPlayer.Character.Head,"text","Red") b.Parent = game.Workspace m.Parent = b b.CanCollide = false b.BottomSurface="Smooth" b.TopSurface="Smooth" b.Material = "Slate" b.Position = Vector3.new(0,6000,0) -- (MouseLocation, Height of the Rock, MouseLocation) b.Shape = "Ball" b.Size = Vector3.new(2048,2048,2048) b.BrickColor = BrickColor.new("Dark stone grey") b.Transparency = 0 wait(10) b:remove() wait(3) end end) end)
Whenever you want to know where the mouse is pointing, just use Mouse.Hit.p
Also, don't use deprecated events like mouse.KeyDown
. Those shouldn't even still exist, they're just around for legacy compatibility.
local player = game.Players.LocalPlayer local ContextActionService = game:GetService("ContextActionService") repeat wait() until player.Character.Humanoid local humanoid = player.Character.Humanoid local mouse = player:GetMouse() local anim = Instance.new("Animation") anim.AnimationId = "http://www.roblox.com/asset/?id=333356213" local function createNewPart(Position) -- Creates new part @Position local newPart = Instance.new("Part", game.Workspace) newPart.CanCollide = false newPart.BottomSurface= "Smooth" newPart.TopSurface= "Smooth" newPart.Material = "Slate" newPart.Position = Position newPart.Shape = "Ball" newPart.Size = Vector3.new(4,4,4) newPart.BrickColor = BrickColor.new("Dark stone grey") newPart.Transparency = 0 end local function onKeyPress(actionName, userInputState, inputObject) -- The new way we are detecting input if actionName == "V" then if userInputState == Enum.UserInputState.Begin then -- When they hit v, even if they didn't let go local newPart = createNewPart(mouse.Hit.p) humanoid:LoadAnimation(anim):Play() -- Play Animation spawn(function() -- Run on a separate thread game:GetService("Chat"):Chat(game.Players.LocalPlayer.Character.Head,"text","Red") wait(1) game:GetService("Chat"):Chat(game.Players.LocalPlayer.Character.Head,"text","Red") wait(1) game:GetService("Chat"):Chat(game.Players.LocalPlayer.Character.Head,"text","Red") wait(8) newPart:Destroy() -- Still 10 seconds before this gets destroyed end) end end end ContextActionService:BindActionToInputTypes("V", onKeyPress, false, Enum.KeyCode.V) -- Whenever a Player hits V, connect