generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: How do you move an object to Player?

Previous Thread :: Next Thread 
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
24 Jan 2017 11:20 PM
Using a script...
Like use Cframe or Vector but it brick (part) get closer to the player 5 steps per second
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
24 Jan 2017 11:23 PM
Take their torso's CFrame
Take the other part's CFrame
Add X to it until it reaches the player.
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
24 Jan 2017 11:25 PM
It's hard to understand to be honest

Can you like give me a line?
or a full script maybe?
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
24 Jan 2017 11:26 PM
EVEN BEFORE I SAW YOUR REPLY I KNEW YOU WERE GOING TO ASK FOR CODE


Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
24 Jan 2017 11:27 PM
IT's because I don't understand...

Come down, it's just script for a game, no big deal okay cupcake?
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
24 Jan 2017 11:29 PM
local pos = player.Character.Torso.Poaition --Scratch the CFrame stuff, it isn't needed actually.
local part = game.Workspace.Part

repeat wait(5) part. = part.Position = part.Position + Vector3.new(10,0,0) until (part.Position-pos).magnitude <=50 end --Obviously this line's going to need lots of tweeking, like which axis to add to and how small the magnitude should be.

Something like that ^
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
24 Jan 2017 11:30 PM
Ok ignore the typos I have transferred over to a tablet so
Another good way to do it would be BosyThrusts.
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
24 Jan 2017 11:31 PM
:o roblox added a new instance??


Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
24 Jan 2017 11:32 PM
@Intended_Pun
I figured it out now!
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
24 Jan 2017 11:36 PM
part. = part.Position = part.Position + Vector3.new(10,0,0) until (part.Position-pos).magnitude <=50 end

Can you add more detail to this line?
Report Abuse
Intended_Pun is not online. Intended_Pun
Joined: 10 Aug 2016
Total Posts: 4384
24 Jan 2017 11:40 PM
The first part is screwed up, it should be

part.Position = part.Position + Vector3.new(10,0,0) until (part.Position-pos).magnitude <=50 end

And it just adds 10 to its position on the x axis until their magnitude is below 50, meaning it's close.
Look up "magnitude" on the wiki.
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
24 Jan 2017 11:46 PM
Player doesn't exist
it's a nil value

Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
24 Jan 2017 11:55 PM
OH no!
YOU Must got it wrong
what i meant is the brick move closer to the PLAYer
not SYnc moving with the playing
Sorry about that
Report Abuse
RogueMage is not online. RogueMage
Joined: 28 Jan 2012
Total Posts: 1235
25 Jan 2017 12:29 AM
Well he literally just told you how to move the brick to the player

Learn from what he showed you and maybe you could tweak the code so it does what you want?
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
25 Jan 2017 02:41 AM
@Mage

The brick moves everytime i moves
And it only moves to the Z or X
it doesn't get closer to me

Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jan 2017 04:03 AM
Yeah what they gave you is wrong.
You want to move it in the direction of (plrPos-objPos).unit

So:
part.Position = part.Position + (plrpos-part.Position).unit*10
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
25 Jan 2017 04:05 AM
#### I changed the script function onPlayerEntered(player) player.CharacterAdded:connect(function(char) while wait() do script.Parent.CFrame = CFrame.new(char:FindFirstChild'Right Leg'.Position) end end) end game.Players.PlayerAdded:connect(onPlayerEntered) But can you help me how to use the Lerp? Because it moves instantly to the Player
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
25 Jan 2017 04:10 AM
function onPlayerEntered(player)
player.CharacterAdded:connect(function(char)
while wait() do
script.Parent.CFrame = CFrame.new(char:FindFirstChild'Right Leg'.Position)
end
end)
end
game.Players.PlayerAdded:connect(onPlayerEntered)

How do you use Lerp??
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
25 Jan 2017 04:23 AM
script.Parent.CFrame = CFrame.new(script.Parent.Position:Lerp(char["Right Leg"].Position, 0.2))

Mathematically this will never end, but computationally it will get close enough where it pretty much does. However this won't move it linearly (if you want that, save the initial position and increase alpha every iteration until 1) but who knows, maybe this is what you want.
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
25 Jan 2017 04:40 AM
I tired to insert that line into my flashlight that makes
the part move to me everytime i use it
Doesn't seem to work

The error says:
17:38:04.597 - CFrame cannot be assigned to
17:38:04.598 - Stack Begin
17:38:04.598 - Script 'Players.Player1.Backpack.Flashlight.ShakeLight', Line 20
17:38:04.598 - Stack End
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
25 Jan 2017 04:40 AM
Here is the flashlight script: local parto = game.Workspace.Part.Position local tool = script.Parent local re = tool:WaitForChild('RemoteEvent') local handle = tool:WaitForChild('Handle') local shake1 = handle:WaitForChild('FirstShake') local shake2 = handle:WaitForChild('SecondShake') local shake3 = handle:WaitForChild('ThirdShake') local light = handle:WaitForChild('SpotLight') local player,char re.OnServerEvent:connect(function(plr) if not player then player,char = plr,plr.Character hum = char:WaitForChild('Humanoid') anim = hum:LoadAnimation(tool.Animation) end if light.Brightness >= 2 then light.Brightness = 2 else parto.CFrame=CFrame.new(parto:Lerp(char:FindFirstChild'RightLeg'.Position,0.1)) anim:Play() shake1:Play() wait(0.2) shake2:Play() wait(0.2) ############# ################ # ################ # #### ### end)
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
25 Jan 2017 04:41 AM
Here is the script i edited:

local parto = game.Workspace.Part.Position
local tool = script.Parent
local re = tool:WaitForChild('RemoteEvent')
local handle = tool:WaitForChild('Handle')
local shake1 = handle:WaitForChild('FirstShake')
local shake2 = handle:WaitForChild('SecondShake')
local shake3 = handle:WaitForChild('ThirdShake')
local light = handle:WaitForChild('SpotLight')
local player,char

re.OnServerEvent:connect(function(plr)
if not player then
player,char = plr,plr.Character
hum = char:WaitForChild('Humanoid')
anim = hum:LoadAnimation(tool.Animation)
end
if light.Brightness >= 2 then
light.Brightness = 2
else
parto.CFrame = CFrame.new(parto:Lerp(char:FindFirstChild'Right Leg'.Position,0.1))
Report Abuse
RomDino is not online. RomDino
Joined: 04 Jul 2015
Total Posts: 2795
25 Jan 2017 04:46 AM
I'm such a dummy
fixed it
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image