Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

homing missle wont work with Mouse.target?

Asked by 6 years ago

how do u use Mouse.target? I have tried every method like this for my homing missile:

local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
function onClicked(playerWhoClicked)
    game.Workspace.Model.rocket.RocketPropulsion.Target = Mouse.Target 
    game.Workspace.Model.rocket.RocketPropulsion:Fire()


script.Parent.ClickDetector.MouseClick:connect(onClicked)

It says Mouse.Target does not exist plz help

1 answer

Log in to vote
0
Answered by 6 years ago

Hi!

The Mouse.Target refers to the object that the mouse is pointing to. Therefore it is a BasePart value, not a position value. What I think you meant to use was Mouse.Hit, a property that refers to the position the mouse is pointing at.

local Player = Game.Players.LocalPlayer
local Mouse = Player:GetMouse()
function onClicked(playerWhoClicked)
    game.Workspace.Model.rocket.RocketPropulsion.Target = Mouse.Hit
    game.Workspace.Model.rocket.RocketPropulsion:Fire()


script.Parent.ClickDetector.MouseClick:connect(onClicked)
Ad

Answer this question