I’m trying to make a missle, but I don’t know how to do movement, the only ways I could think of are way way over complicated for my level of coding (this is in a tool)
LocalScript:
local RemoteEvent = script.Parent:WaitForChild("RemoteEvent")
local tool = script.Parent
local Player = game.Players.LocalPlayer
tool.Activated:Connect(function()
RemoteEvent:FireServer(Player)
end)
Server:
local RemoteEvent = script.Parent:WaitForChild("RemoteEvent")
local tool = script.Parent
local Missle = game:GetService("ServerStorage"):WaitForChild("Missle")
RemoteEvent.OnServerEvent:Connect(function(player)
local ClonedMissle = Missle:Clone()
ClonedMissle.Parent = workspace
ClonedMissle.Position = Vector3.new(player.Character.HumanoidRootPart.Position.X, player.Character.HumanoidRootPart.Position.Y + 100, player.Character.HumanoidRootPart.Position.Z)
end)
4 Likes
For this u can shorten it to
ClonedMissle.Position = player.Character.HumanoidRootPart.Position += Vector3.new(0,100,0)
If ur talking abt like a nuclear missile or something that falls down you could tween it down :3
2 Likes
nope I meant something you could use with WASD but thanks
1 Like
you could do
local humPos = player.Character.HumanoidRootPart.Position
for i = 1, 100 do
ClonedMissle.Position = Vector3.new(humPos.X, humPos.Y + 1, humPos.Z) --edited here
task.wait(0.1)
end
i have not tested this, so it may not work
1 Like
okay, i’ll test it, but I wanted something more smooth! thank you
this will send the missile up 100 studs by increments of 1 stud at a time
Ohhhhhh… then what @redwoodsteve said would probs work
Wouldn’t it like grow exponentially higher cuz i is always increasing?
you could use tweenService to tween the missile smoothly upwards, but it will not be affected by physics until the tween ends so the missile could go through roofs
local ts = game:GetService("tweenService")
local ti = TweenInfo.new(10,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,0,false,0)
local goals = {["Position"] = player.Character.HumanoidRootPart.Position += Vector3.new(0,100,0)}
local tween = ts:Create(ClonedMissle,ti,goals)
tween:Play() --play the tween (send missile upwards)
nvm I miss read your code I want it to teleport up and then like be able to control it from the sky not smoothly go up there and then when it hits the ground it makes what ever it hit blow up!
i fixed my error (instad of “humPos.Y + i” it is “humPos.Y + 1”)
1 Like
hmm that would be difficult
you could use userInputService to detect when the player presses w,a,s or d then change the missile’s position accordingly
then anchor the player’s humanoidRootPart so they dont move their character while they are moving the missile
now just set the cameraType of workspace.currentCamera to scriptable and set its position to behind the nuke
edit: you would have a variable like “controllingMissile” as a boolean to detect if the player is currently controlling the missile
Use a Touched event for the missile and check if the object/instance it touched isn’t the missile itself
that’s what I would of done for the camera, but the movement is why I created this devfourm post!
I use a single mesh for the missle so it would be okay
nice, so all you have to detect the player’s input
the easiest way is to use userInputService, but on mobile you would not be able to control the missile
example:
game:GetService("UserInputService").InputBegan:Connect(function(input,gpe)
if not gpe and input.KeyCode == Enum.KeyCode.W then
--update missile position to go forwards
end
end)
okay thanks! I’ll try that, i’ll try to find a mobile way but if you find one please tell me!
this article might help with mobile movement
or you could just create a GUI with buttons for forwards, backwards, left and right
okay thanks! do you know a way to constantly move the mesh forward vector forces won’t work because they don’t work on meshs! thanks in advance
increment short amounts in short periods of time?
while true do
move(0.01,0,0) --pretend function
task.wait(0.01) --task.wait() is recommended over wait()
end