|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 09 Apr 2016 12:32 PM |
| add: and if torso ~= localplayer.character.torso |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 09 Apr 2016 01:07 PM |
| sorry, not a certain area, to the nearest humanoid and torso |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
|
| 09 Apr 2016 02:08 PM |
halp
i've pondering wtf is wrong with this script for 2 days now qq |
|
|
| Report Abuse |
|
|
|
| 09 Apr 2016 02:10 PM |
I'll have one fried brain please. To go
|
|
|
| Report Abuse |
|
|
| |
|
| |
|