Recently I'm trying to make something akin to a remake of plants vs zombies on Roblox, but I ran into a problem. I'm trying to make it so when a player clicks on a "seed slot," it will get the players mouse and wait for it to click again somewhere so that it moves the model.
SeedSlot2.ClickDetector.MouseClick:Connect(function(player)
print ("Clicked")
LSV = SeedSlot2.SunValue.Value
lowerSun()
local newP = game.ServerStorage.Peashooter:Clone()
newP.Parent = game.Workspace
print ("Player who clicked is.. " ..player.Name)
local mouse = player:GetMouse()
local target = mouse.Hit.Position
newP:MoveTo(Vector3.new(target))
end)
Ignore the "LSV" and "lowersun," that has nothing to do with it. Right now all it does is clone the plant model from the server storage but leaves it at it's original position without moving it; if I keep pressing the seed slot it will just keep making towers of plants. It also gives the error "Position is not a valid member of CFrame" for line 9. It would be nice if you could say what you use instead of Position.
Please reply as soon as you can, i'd really appreciate it :)

3 comments
Thank's, but there's still something i'm trying to solve. I need the script to wait for the player to click again after pressing the click detector somewhere on the ground before the script can continue to move the model. Is there a way to wait until the player clicks again?
Do you want the player click twice before the movement happens?
This helps a lot, thanks for the extra code. Now I can finally start working on other parts of the game.