Categories > Coding > Lua >

Farming help

Posts: 196

Threads: 58

Joined: Apr, 2020

Reputation: 3

Posted

How would I make one of those farming scripts where they go to an NPC and

they start to deal damage while like underground or like on top of the NPC

so they don't deal damage to your avatar?

Is there anything I have to do like get the coordinates of the NPCs and make a no clip script or??

If someone can link me to some script tutorials will so appreciate it.

  • 0

indigiz

google is best

Posts: 248

Threads: 8

Joined: Feb, 2021

Reputation: 0

Replied

i   h a v e   n o   i d e a

  • 0

【˜”*°•.˜”*°• 𝕚𝕟𝕕𝕚𝕘𝕚𝕫 •°*”˜.•°*”˜】

 

eb_

Formally known as Shade

vip

Posts: 923

Threads: 4

Joined: Jun, 2020

Reputation: 44

Replied

I've made something similar to this before which is open source on my github for a simulator. How I did it:

 

When attacking that model it gave off a remote, I use that remote and put it into a loop so it would constantly fire it. via a remote spy and some lua code

 

Then I made my player teleport to that exact location so it was in range to hit that model and for the remote to work via your players hunaoid cframe 

 

And for me to control it for when to stop and start I used getgenv() to control via game environment

 

Example:

 

getgenv().Farm = true
while wait() do
if getgenv().Loop == true then 
 --teleport the player via the humanoid cframe and fire remote 
else
-- do nothing, stop firing remote and let the walk free instead of teleporting them
end
end

Hope this helped.

  • 0

https://media.discordapp.net/attachments/1010636204225601659/1012865624797610044/sKQybOLT.gif

Posts: 196

Threads: 58

Joined: Apr, 2020

Reputation: 3

Replied

@eb_

I watched a tutorial and scripted this

getgenv().farmer = true;

 

while wait() do

    if getgenv().farmer == true then

        game:service'ReplicatedStorage'.Modules.Network.RemoteEvent:FireServer("punchHumanoid");

    end

end

 

So do I remake it like this

 

getgenv().farmer = true;

 

while wait() do

    if getgenv().farmer == true then

        if getgenv().Loop == true then if getgenv().Loop == true then

        game:service'ReplicatedStorage'.Modules.Network.RemoteEvent:FireServer("punchHumanoid");

        end

end

end

 (It sais 'end' expected near '<eof>') so I don't really know what I'm doing wrong or if this is even right? Even if I remove it it goes to line 8 and says the same thing

 

  • 0

eb_

Formally known as Shade

vip

Posts: 923

Threads: 4

Joined: Jun, 2020

Reputation: 44

Replied

@DadComeBack why are using some many getgenv() u only need one for one action:

getgenv().farmer = true -- game environment 

while wait() do -- while you wait it will do
 if getgenv().farmer == true then -- if getgenv().farmer is true then it will do
  game:GetService("ReplicatedStorage").Modules.Network.RemoteEvent:FireServer("punchHumanoid") -- will now continuously fire this remote is getgenv().farmer is true
  print("on") -- this is for testing to indicate when it is on or off
 else -- else if getgenv().farmer isnt true it will do 
  print("off") -- this is for testing to indicate when it is off or on 
 end -- for getgenv()
end -- for while wait() do

I was in my phone writing this so if I misspelled something correct me anyone 

  • 0

https://media.discordapp.net/attachments/1010636204225601659/1012865624797610044/sKQybOLT.gif

Posts: 196

Threads: 58

Joined: Apr, 2020

Reputation: 3

Replied

@eb_

Wait I wrote the script wrong I accidently forgot to check the remote spy since I played a different game before so I edited it this is what I made for the game I want to auto farm.

 

getgenv().farmer = true;

 

while wait() do

    if getgenv().farmer == true then

        game:service'ReplicatedStorage':FireServer("punchHumanoid");

    end

end

 

So then I edited your script.

 

getgenv().farmer = true -- game environment 

 

while wait() do -- while you wait it will do

 if getgenv().farmer == true then -- if getgenv().farmer is true then it will do

  game:GetService("ReplicatedStorage").RemoteEvent:FireServer("punchHumanoid") -- will now continuously fire this remote is getgenv().farmer is true

  print("on") -- this is for testing to indicate when it is on or off

 else -- else if getgenv().farmer isnt true it will do 

  print("off") -- this is for testing to indicate when it is off or on 

 end -- for getgenv()

end -- for while wait() do

 

When I executed it it spammed ReplicatedStorage.RemoteEvent ("punchHumanoid")

It does nothing when I executed the original script you gave me it didn't work.

Then I tried turning it off by doing this

 

getgenv().farmer = false -- game environment 

 

while wait() do -- while you wait it will do

 if getgenv().farmer == false then -- if getgenv().farmer is true then it will do

  game:GetService("ReplicatedStorage").RemoteEvent:FireServer("punchHumanoid") -- will now continuously fire this remote is getgenv().farmer is true

  print("on") -- this is for testing to indicate when it is on or off

 else -- else if getgenv().farmer isnt true it will do 

  print("off") -- this is for testing to indicate when it is off or on 

 end -- for getgenv()

end -- for while wait() do

 

It then spammed Off so I might figure out how to break the loop of the script later.

So basically It does nothing which I'm trying to figure out I'm figuring I have to find the npc folder thing and put the directory folder like game:GetService("ReplicatedStorage") and then it would damage the npc. So I found the directory folder and its game.Workspace.npcs so all the npcs are there. I searched up the game then script then I found one and its like

 

function FindClosestPlayer()

local sdist = math.huge

local nearest = nil

for k,v in ipairs(game.Workspace.npcs:GetChildren()) do

if v.Name ~= game.Players.LocalPlayer.Name then

local cdist = (game.Players.LocalPlayer.Character.HumanoidRootPart.Position - v.HumanoidRootPart.Position).magnitude

if cdist < sdist then

sdist = cdist

nearest = v

end

end

end

return nearest

end

while wait() do

local plr = FindClosestPlayer()

game:GetService("ReplicatedStorage").RemoteEvent:FireServer("punchHumanoid", plr)

end

 

I want to script this but like you fly/float to the npc and you deal damage just like AutoFarms for Ro-Ghoul that's why I'm trying to script 

the damage to npc script then the fly/float to npc script.

The script above deals damage to the npcs but only if your super close and I want the npc to have a bigger hitbox.

I have a few ideas on what I should do for an AutoFarm but I'm 2 lazy to explain.

 

 

  • 0

Users viewing this thread:

( Members: 0, Guests: 1, Total: 1 )