im trying to make a block move to my mouses position everytime i tap f but it keeps moving to where i spawned heres my script
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local mp = mouse.Target.Position local m = game.Players.LocalPlayer:GetMouse() db = true m.KeyDown:connect(function(k) k = k:lower() if k == "f" then if db == true then game.Workspace.Part.Position = mp db = false wait(3) db = true end end end)
UIS = game:GetService("UserInputService") local player = game.Players.LocalPlayer local mouse = player:GetMouse() db = true UIS.InputBegan:Connect(function(k, process) if k.KeyCode == Enum.KeyCode.F then if db == true then game.Workspace.Part.Position = mouse.Hit.Position db = false wait(3) db = true end end end)
This is not an answer We just can't see the code
local player = game.Players.LocalPlayer local mouse = player:GetMouse() local mp = mouse.Target.Position local m = game.Players.LocalPlayer:GetMouse() db = true m.KeyDown:connect(function(k) k = k:lower() if k == "f" then if db == true then game.Workspace.Part.Position = mp db = false wait(3) db = true end end end)
That's ur code and I don't recommend KeyDown because it is deprecated. Youtube can be a good source for scripting but some scripts are bad. UserInputService is a pretty good one. I'll show u.
UIS = game:GetService("UserInputService") local player = game.Players.LocalPlayer mouse = player:GetMouse() local mp = mouse.Hit.Position --we use hit.Position not Target.Position db = true
UIS.InputBegan:Connect(function(k, process)--k is what the person pressed if k.KeyCode == Enum.KeyCode.F then if db == true then game.Workspace.Part.Position = mp db = false wait(3) db = true end end end)
not 100% sure the script works because I'm not good with CFrame but I'm positive that we use mouse.Hit.p