#Bug problem

1 messages · Page 1 of 1 (latest)

atomic sparrow
#

Helpppp fast !!!

#
local part = script.Parent
part.Touched:Connect(function(touch)
    local plr = game.Players:GetPlayerFromCharacter(touch.Parent)
    local leaderstats = plr:FindFirstChild("leaderstats")
    if leaderstats then
        local coins = leaderstats:FindFirstChild("Coins")
        local clicks = leaderstats:FindFirstChild("Clicks")
        coins.Value += clicks.Value
        clicks.Value = 0
    end
end)
#

why sometimes line 4 send me problem

#

sometimes not everytime

agile dagger
#

then game.Players:GetPlayerFromCharacter(touch.Parent) returns nil

agile dagger
#

and plr:FindFirstChild("leaderstats") errors

#

you can fix this by adding a guard clause after line 3

#

if not plr then return end

#

it exits the function if a player isnt found

atomic sparrow
#

soo there is other way like

#

there is parts of plr not in anything else right ?

agile dagger
atomic sparrow
#

idk how to say it

#

ok np ty for helping

atomic sparrow
#

@agile dagger

agile dagger
#

the errors will fill up the console

#

but not really anything else

atomic sparrow
agile dagger
#

the script makes errors

#

and the errors go in the console

#

and can be annoying

atomic sparrow
#

there is better way to idenfy player ?

#

like not local plr = game.plr....

agile dagger
#

your way works fine but you can just use the fix i said

atomic sparrow
#

can i add like if plr then and add everything start from line 5 and else then print ("wrong" )

agile dagger
#

yeah

agile dagger
atomic sparrow
#

ok but better return right ?

atomic sparrow
agile dagger
#

return exits a function

#

;compile

local function A()
  print("Hello World!")

  return

  print("This won't print")
end

A()
print("a")
tardy forgeBOT
#
Program Output
Hello World!
This won't print
a

agile dagger
#

what

#

;compile

local function foo()
  print("Hello World!")

  return 3

  print("This won't print")
end

foo()
print("a")
tardy forgeBOT
#
Program Output
/opt/wandbox/lua-5.4.7/bin/lua: prog.lua:6: 'end' expected (to close 'function' at line 1) near 'print'

agile dagger
#

ohhh

#

;compile

local function A()
  print("Hello World!")

  return;

  print("This won't print")
end

A()
print("a")
tardy forgeBOT
#
Program Output
/opt/wandbox/lua-5.4.7/bin/lua: prog.lua:6: 'end' expected (to close 'function' at line 1) near 'print'

agile dagger
#

yeah so it just expects the function to close there

#

but return exits a function

atomic sparrow
#

oh okk

#
local part = script.Parent
part.Touched:Connect(function(touch)
    local plr = game.Players:GetPlayerFromCharacter(touch.Parent)
    local leaderstats = plr:FindFirstChild("leaderstats")
    if plr then
        if leaderstats then
            local coins = leaderstats:FindFirstChild("Coins")
            local clicks = leaderstats:FindFirstChild("Clicks")
            coins.Value += clicks.Value
            clicks.Value = 0
        end
    end
    else 

end)

#

there is problem in else

#

oh i put else in wrong place

#

tysmmmm it worked

#
local part = script.Parent
part.Touched:Connect(function(touch)
    local plr = game.Players:GetPlayerFromCharacter(touch.Parent)
    if plr then
        local leaderstats = plr:FindFirstChild("leaderstats")
        if leaderstats then
            local coins = leaderstats:FindFirstChild("Coins")
            local clicks = leaderstats:FindFirstChild("Clicks")
            coins.Value += clicks.Value
            clicks.Value = 0
        end
    else 
        return
    end
end)
#

here ty very much

agile dagger
#

well you don't even need the return there

#

because you put eveyrthing in the if statement

atomic sparrow
#

ohh okk

#

@agile dagger can i ask u diffrante thing

agile dagger
#

ok

atomic sparrow
#

then how i reach to humanoid part of plr

#

like if click on button or touch something

#

@agile dagger

red nightBOT
#

studio** You are now Level 8! **studio

fossil bone
#

what you're saying is confusing

#

like what exactly are you asking

#

reword it perhaps

atomic sparrow
#

I just figure it out but i have doffrante problem 😦

fossil bone
#

describe it in a way that makes sense

atomic sparrow
#

ahhh chatgpt say it to me

#

i forgot = sign after 80 lines of codes Y_Y

fossil bone
#

I wouldn't rely on using chatgpt too much if you can't properly understand the code it writes

#

because it can make mistakes and you wouldn't be able to figure out the mistake since you can't figure out how the code works exactly

atomic sparrow
fossil bone
#

yeah but chatgpt can make alot of mistakes

#

it can teach you the wrong things

atomic sparrow
#

yeah happen alot also lol

#

but i just use it as fast respond and if it got it wrong i come ask here

#

@fossil bone u know rebirth calculation and like this

fossil bone
#

you mean like simulator rebirths?

atomic sparrow
#

like i did intvalue in replicated storge that i put value of it 1 so every click it gives 1

#

but i want each rebirth increase makes click value in replicated storge increase 10%

#

like if it gives 1 per click next gives 1.1 , and when uget 2 rebirth it increase 1.1 by 10%

#

u understand ?

fossil bone
#

define a variable for their amount of rebirths

#

then do something like this

#

wait

#

do you want it to be only whole numbers

#

or include decimals

atomic sparrow
#

decimals

fossil bone
#

ok then

#

what you'll wanna do is

#

first define the amount of rebirths they have

#

then do

atomic sparrow
#

i want math calculation to see rebirth value like
click value =rebirth +0.5 *3

#

for example

fossil bone
#

ok so we have their rebirths

#

you'd need to do something like the multiplication value

#

make that

#

0.1*(1^#rebirths)

#

then you have that value defined

atomic sparrow
#

what is # ?

fossil bone
#

multiplication = 0.1*(1^#rebirths)

#

then do

#

1 + multiplication

#

then you have your clicks

fossil bone
#

for number

#

meaning the number of rebirths the player currently has

atomic sparrow
#

uamm thatss too much i just want i create script in server service that every time check rebirth value and
make calculation click value = rebirthvalue *2

fossil bone
#

wait no

#

that's wrong

#

lemme redo

atomic sparrow
#

for example

#

i only need the calculation click value = rebirthvalue * + what

#

soo rebirth gives 10% more click value each time i increase

fossil bone
#

the equation would be like this

#

1(1.1^#rebirths)

#

i believe

atomic sparrow
#

#rebirth ?

fossil bone
#

again

#

that's just an abbreviation

atomic sparrow
#

can i delete it ?

fossil bone
#

no

#

replace it with a variable that defined the amount of rebirths the user has

atomic sparrow
#

here what i mean

#

finalClickValue = baseClickValue * (1.1 ^ rebirths)

#

chat gpt did it its right ?

fossil bone
#

well that's exactly what I did

#

what I came up with is 1 + 1(1.1^1)-1

#

the first 1 is the base click value

#

assuming you it never gets increased

#

otherwise simply just do

atomic sparrow
#

ohh okk but can u tell me how u got this calculation lol

#

u know it or do it steps ?

fossil bone
#

this is what you want to use for the rebirth addition

fossil bone
#

what

atomic sparrow
#

ohh nice

#

how !

fossil bone
#

baseclickvalue + baseclickvalue(1.1^#rebirths)-baseclickvalue

#

that's what you want to do for just the rebirth multiplication

#

if you want it to be the final calculation from the get go just do baseclickvalue + baseclickvalue(1.1^#rebirths)

atomic sparrow
#

okk tysm

fossil bone
#

if you provide a script for me I can perhaps give you an example

atomic sparrow
#

but script doesnt work

fossil bone
atomic sparrow
#
game.Players.PlayerAdded:Connect(function(plr)
    while wait() do
        local click_value = game.ReplicatedStorage.Click_Value.Value
        local leaderstats = plr:WaitForChild("leaderstats")
        if leaderstats then 
            local rebirth = leaderstats:FindFirstChild("Rebirth")
            if rebirth then
                local newClickValue = click_value * (1.1 ^ rebirth.Value)
                click_value = newClickValue
            end
        end
    end
end)

#

doesnt change click value

fossil bone
#

whats the error

#

does it error

atomic sparrow
#

nope just doesnt change click value

fossil bone
#

so it stays at one

#

or it doesn't change the value of clicks at all?

atomic sparrow
#

doesnt change

red nightBOT
#

studio** You are now Level 16! **studio

fossil bone
#

does your player have 0 rebirths

atomic sparrow
#

1

#

ohh i understand why maybe

#

i should add first line click value = 1

#

@fossil bone nothing work

fossil bone
#

I'm looking at the script rn

#

hold on

#

that's strange because looking at the script i assume it would work

#

one question

atomic sparrow
#

yes but doesnt change click value

fossil bone
#

is the value inside replicated storage a intvalue

#

or a number value

#

like the instance type

atomic sparrow
#

intvalue

fossil bone
#

with no multiplication?

atomic sparrow
#

what u mean ?

fossil bone
#

delete it

atomic sparrow
#

oh

fossil bone
#

and replace it with a number value

#

int value only take whole numbers

#

no decimals

#

number values take decimals

atomic sparrow
#

ohhh that something new

fossil bone
#

just replace it as a numbervalue and rename it

atomic sparrow
#

okk tysm

fossil bone
#

see if that makes it work now

#

tell me if it does

atomic sparrow
#

now it doesnt even click

fossil bone
#

wdym

#

does it error out

atomic sparrow
#

nothing

#

ohh wit i forgot to change value to 1

fossil bone
#

ok what now

atomic sparrow
#

so its at rebrith 1 still gives 1 not 1.1

fossil bone
#

make your rebirths 2

#

see what it does

atomic sparrow
#

ok

#

1 min

#

yeah still 1

fossil bone
#

that is actually so weird

#

show me your updated code

#

this would be so much easier for me to fix if I was actually on pc lol

atomic sparrow
#

oh for sure

#
game.Players.PlayerAdded:Connect(function(plr)
    while wait() do
        local click_value = game.ReplicatedStorage.Click_Value.Value
        local leaderstats = plr:WaitForChild("leaderstats")
        if leaderstats then 
            local rebirth = leaderstats:FindFirstChild("Rebirth")
            if rebirth then
                local newClickValue = click_value * (1.1 ^ rebirth.Value)
                click_value = newClickValue
            end
        end
    end
end)
#

and now click_value is numbervallue not int value

fossil bone
#

you something I'm starting to realize

atomic sparrow
#
        local click_value = game.ReplicatedStorage.Click_Value.Value

``` i think bec this line in while true
fossil bone
#

is that this script is only defining the value of the clicks once

#

can you show me the code for the button that you use to clicj

#

or whatever

atomic sparrow
#

its screen

#

ok

fossil bone
#

yes just show me the script for clicking

#

like this script seems formatted so weirdly

atomic sparrow
#

okk

fossil bone
#

is it a local script?

#

gui

atomic sparrow
#

yeah

#

but remote event

#
local plr = game.Players.LocalPlayer
local mouse  = plr:GetMouse()
local click_value = game.ReplicatedStorage.Click_Value.Value
local bag = game.ReplicatedStorage.BagValue.Value
local bag_value = bag -1
local click_event = game.ReplicatedStorage.Click

mouse.Button1Down:Connect(function(click)
    local leaderstats = plr:FindFirstChild("leaderstats")
    if leaderstats then
        local clicks = leaderstats:FindFirstChild("Clicks")
        if clicks then
            if clicks.Value <= bag_value then
                click_event:FireServer()
            end
        end
    end
end)
fossil bone
#

is it that it fires a remote event

#

oh

atomic sparrow
#

in starter player script

fossil bone
#

ok so what's the script for the clickevent

#

you fire an event to the server correct

#

you'd have a script somewhere respond to it

atomic sparrow
#
local click_event = game.ReplicatedStorage.Click
local click_value = game.ReplicatedStorage.Click_Value.Value
click_event.OnServerEvent:Connect(function(plr)
    local leaderstats = plr:FindFirstChild("leaderstats")
    if leaderstats then
        local clicks = leaderstats:FindFirstChild("Clicks")
        if clicks then
            clicks.Value += click_value
        end
    end
end)
#

htere is serverscript service

fossil bone
atomic sparrow
#

bec clint to server for data save

atomic sparrow
fossil bone
#

wait

#

lemme do smth

atomic sparrow
fossil bone
#

wait bro

#

my phone is dogshit

#

I'm tryna do smth with the script

atomic sparrow
#

np take your time

atomic sparrow
fossil bone
#

you might not get what I mean

#

it's just a pain in the ass to code on mobile

atomic sparrow
#

soo what i do wrong i just do event from local to script

#

i gtg very soon

fossil bone
#

with this

#

local click_event = game.ReplicatedStorage.Click
click_event.OnServerEvent:Connect(function(plr)
local click_value = game.ReplicatedStorage.Click_Value.Value
local leaderstats = plr:FindFirstChild("leaderstats")
if leaderstats then
local clicks = leaderstats:FindFirstChild("Clicks")
if clicks then
clicks.Value += click_value
local rebirth = leaderstats:FindFirstChild("Rebirth")
if rebirth then
click_value = click_value*(1.1^rebirth.Value)
end
end
end
end)

#

see if that works

#

if it doesn't then you'll need to wait till I get home to help you because using mobile to code is literal asscheeks

atomic sparrow
#

ohhh

#

ok

fossil bone
#

like the server event script

atomic sparrow
#

still 1 click value

fossil bone
#

and you have 1 rebirth?

atomic sparrow
#

2

fossil bone
#

hmmm

#

I guess I'll just wait till I get home to help you

#

because mobile is absolutely atrocious to code

atomic sparrow
#

okk

#

i will try to ask chatgpt

fossil bone
#

no don't the solution is actually really simple

#

I can fix it

#

all chatgpt will do is make the problem worse probably

#

trust me i know because I've used chatgpt before to help and it can make things worse

atomic sparrow
#

oh ok

#
local click_event = game.ReplicatedStorage.Click
click_event.OnServerEvent:Connect(function(plr)
    local click_value = game.ReplicatedStorage.Click_Value.Value
    local leaderstats = plr:FindFirstChild("leaderstats")
    if leaderstats then
        local clicks = leaderstats:FindFirstChild("Clicks")
        local rebirth = leaderstats:FindFirstChild("Rebirth")
        if clicks and rebirth then
            click_value = click_value*(1.1^rebirth.Value)
            clicks.Value += click_value
        end
    end
end)
#

here what i did but still problem there

#

@fossil bone nvm i will just delete rebirth

fossil bone
atomic sparrow
#

no no i will just delete it

fossil bone
#

this problem seems so stupidly simple

#

it's probably just some small thing you don't notice that's causing it to not work

atomic sparrow