Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why does Model not move to position of the mouse?

Background: So I'm building a game like Clash of Clans, and I notice when I to :MoveTo(), it doesn't work. Beause I print the Vector3.new(mouse.Hit) it says 0, 0, 0.

Fail Solution: - I try doing :SetPrimaryPartCFrame(), it does weird "things".

  • I also try doing :TranslateBy(), it's an error.
local mouse = game.Players.LocalPlayer:GetMouse()
local ar = false


script.Parent.Equipped:Connect(function()
	print("TRUE")
	if ar ~= true then
		ar = true
		local f = Instance.new("Folder", workspace.PlayerBuilding)
		f.Name = game.Players.LocalPlayer.Name
		
		local w = game:GetService("Lighting").Level1Wall:Clone()
		w.Parent = f
	end
end)
script.Parent.Unequipped:Connect(function()
	print("TRUE")
	ar = false
	workspace.PlayerBuilding:FindFirstChild(game.Players.LocalPlayer.Name):Destroy()
end)

while wait(0.01) do
	if workspace.PlayerBuilding:FindFirstChild(game.Players.LocalPlayer.Name) then	
		local wa = workspace.PlayerBuilding:FindFirstChild(game.Players.LocalPlayer.Name).Level1Wall
		wa:MoveTo(Vector3.new(mouse.Hit))
	end
end

1 answer

At line 24, you have to add "mouse.Hit.p" instead of "mouse.Hit"

local wa = workspace.PlayerBuilding:FindFirstChild(game.Players.LocalPlayer.Name).Level1Wall

wa:MoveTo(Vector3.new(mouse.Hit.p))

Also check the Model API for more information on moving the Model

http://wiki.roblox.com/index.php?title=API:Class/Model

I hope I helped you!

3 comments

0

Thank you for you answer! I will accept it once it work.

0

Alright, thanks.

0

Yeah it doesn't work

This discussion is preserved as it was. New answers, comments, and votes are closed.