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: my brain is fried

Previous Thread :: Next Thread 
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 11:50 AM
i have worked on a script for so long, i pretty much gave up

all i need is that when you press a key, it'll teleport you to the nearest humanoid that has a torso

heres the useless script:

plr = game.Players.LocalPlayer
Character = plr.Character
Mouse = plr:GetMouse()

function onKeyDown(key)
key = key:lower()
if key == "p" then
local function getClosestTorso()
local closest = {nil, 10000} --part, distance
for i, p in pairs(game.Players:GetPlayers()) do
if p.Character and Character ~= p.Character and p.Character:FindFirstChild("Torso") and p.Character:FindFirstChild("Enemy") then
local mag = (Character.Torso.Position - p.Character.Torso.Position).magnitude
if mag < closest[2] then
closest = {p.Character.Torso, mag}
Character:MoveTo(getClosestTorso())
end
end
end
return closest[1]
end
end
wait(3)
script.Disabled = true
wait(3)
wait(2)
script.Disabled = false
end

Mouse.KeyDown:connect(onKeyDown)
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 11:51 AM
it keeps teleport to the player itself (i think), and i have no idea on how to fix that
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 12:29 PM
bump
Report Abuse
Bernkastel2727 is not online. Bernkastel2727
Joined: 23 Sep 2012
Total Posts: 2612
09 Apr 2016 12:32 PM
add: and if torso ~= localplayer.character.torso
Report Abuse
Bernkastel2727 is not online. Bernkastel2727
Joined: 23 Sep 2012
Total Posts: 2612
09 Apr 2016 12:41 PM
Or try this:


local player = game.Players.LocalPlayer
local char = player.Character
local torso = char.Torso

repeat wait() until char

local radius = 20

local part = Instance.new("Part", char)
part.Name = player.UserId
local mesh = Instance.new("CylinderMesh", part)
mesh.Offset = Vector3.new(0, -3.05, 0)
mesh.Scale = Vector3.new(radius * 2, 1, radius * 2)
part.FormFactor = "Custom"
part.CanCollide = false
part.Size = Vector3.new(1, 0.2, 1)
part.BrickColor = BrickColor.new("Really red")
part.TopSurface = "Smooth"
part.BottomSurface = "Smooth"
part.Transparency = 0.5

local weld = Instance.new("Weld", part)
weld.Part0 = part
weld.Part1 = char:findFirstChild("Torso")

function onTouched(part)
if part.Parent ~= nil then
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil and h~=player.Character.Humanoid then
torso.Parent:MoveTo(part.Position)
end
end
end
part.Touched:connect(onTouched)
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 01:06 PM
wont work either
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 01:07 PM
what im trying to do is when you press the p key, you move to a certain area
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 01:07 PM
sorry, not a certain area, to the nearest humanoid and torso
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 01:27 PM
ello?
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 01:42 PM
bump
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 01:52 PM
ellooo??
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 02:08 PM
halp

i've pondering wtf is wrong with this script for 2 days now qq
Report Abuse
arshiaslaya is not online. arshiaslaya
Joined: 04 Nov 2012
Total Posts: 2670
09 Apr 2016 02:10 PM
I'll have one fried brain please. To go


Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 02:12 PM
That'll be $9.99
Report Abuse
Alimegacorn is online. Alimegacorn
Joined: 24 May 2013
Total Posts: 899
09 Apr 2016 02:22 PM
bump 666
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