#im lowk a dumbass and i need help

1 messages · Page 1 of 1 (latest)

thick mirage
#

idk whats wrong

#

l```lua
local Part = script.Parent

Part.Touched:Connect(function(otherPart)
local Humanoid = otherPart.Parent:WaitForChild("Humanoid")

if Humanoid then
    Humanoid.Health = 50
local Egg = math.random(1, 800)

while Egg <= 800 do
        if Egg <= 10 then
            print("???")
        elseif Egg <= 75 then
            print("Godly")
        elseif Egg <= 185 then
            print("Mythic")
        elseif Egg <= 285 then
            print("Legendary")
        elseif Egg <= 385 then
            print("Epic")
        elseif Egg <= 485 then
            print("Rare")
        elseif Egg <= 585 then
            print("Uncommon")
        elseif Egg <= 700 then
            print("Common!")
        elseif Egg == 800 then
            print("You're a Bum.")
            task.wait(2)
        if Egg == 5 then
            break
            
            end
        end

end
    
end

end)

#

@fading shore

fluid zodiacBOT
#

studio** You are now Level 1! **studio

deft dirge
#

what do u need help with

thick mirage
#

the break

#

or wtv

deft dirge
#

well, all it does is bring a useless loop and get egg's value once

stray drum
thick mirage
#

but

#

i thought u have to use it

#

since

#

i dont want it launching as soon as i run the game

stray drum
#

that’s what the “if Humanoid” is for

thick mirage
thick mirage
stray drum
#

Yes

deft dirge
stray drum
#

Also what’s the script doing

thick mirage
#

idk

#

i js want it to give you a result with the math.random thing

stray drum
thick mirage
#

mb

thick mirage
deft dirge
stray drum
#

I hate scripting on a phone

stray drum
thick mirage
#

bru

#

like

#

yk

#

how in simulator games

#

when u roll a pet

stray drum
#

also you don’t need a while loop

thick mirage
#

what loop do i nede

#

need

stray drum
#

so look

#

That entire function will start every time a player touches the part

#

Instead of a while loop just do the if statements

#

You don’t need a loop if it’s going to give you a item every time it’s touched otherwise it’ll infinitely print until you hit the 5

deft dirge
#

Part.Touched:Connect(function(otherPart)
    local Humanoid = otherPart.Parent and otherPart.Parent:FindFirstChild("Humanoid")
    if not Humanoid then return end

    if Humanoid then
        local Egg = math.random(1, 800)
        
        if Egg <= 10 then
            print("???")
        elseif Egg <= 75 then
            print("Godly")
        elseif Egg <= 185 then
            print("Mythic")
        elseif Egg <= 285 then
            print("Legendary")
        elseif Egg <= 385 then
            print("Epic")
        elseif Egg <= 485 then
            print("Rare")
        elseif Egg <= 585 then
            print("Uncommon")
        elseif Egg <= 700 then
            print("Common!")
        elseif Egg == 800 then
            print("You're a Bum.")
        end
    end
end)```
this one prints everytime a part of your body touches
fluid zodiacBOT
#

studio** You are now Level 1! **studio

deft dirge
#

i can edit it so you need to touch once for infinite replies

#

its just changing how u get humanoid

#

removed loop

thick mirage
#

so what was the error?

deft dirge
#

and getting value of 5

thick mirage
#

just the loop?

deft dirge
#

yeah

thick mirage
#

why did u add

#

if not Humanoid then return end

#

i thought when u introduce it

deft dirge
thick mirage
#

its always going to be true

#

ohhh

thick mirage
deft dirge
stray drum
#

yeah

thick mirage
stray drum
#

it’s also unnecessary resource usage

thick mirage
deft dirge
#

if not game.Players:GetPlayerFromCharacter(otherPart.Parent) then return end
also works

stray drum
#

yooo thats tuff

fluid zodiacBOT
#

studio** You are now Level 2! **studio

thick mirage
#

@deft dirge

deft dirge
thick mirage
#

ion get it bru

deft dirge
#

Basically ends the code there

#

Or ```local function hi()
return "hi"
end

Hello = hi()

#

This will make Hello be "hi"

vague pine
# thick mirage ion get it bru

Return can makes you "escape" the function, so you tell the code of the function to stop where u put return, return could also be used to return us values, what do i mean by thats, is that if we make a function


local function addition(number1,number2)
  local number3 = number1 + number2
  return number3
end

local result = addition(5,2) -- result = 7 since number 3 with this function is 7, and we said the function that it will be equal to number3 
--another ewample
local otherResult = addition(3,2) -- 5 since here number3 is equal to 5

#

And if u still dont understand dont worry, if we keep saying the same thing, a time will come u will understand immediatly