#can someone help with fixing a script .

645 messages · Page 1 of 1 (latest)

unique ingot
#

Whats all the update part position thing about?

#

Also ur not at any point adding to the players leaderstats

cursive urchin
#

can you help me bc i dont understand quit

#

local part = workspace.Assets:WaitForChild("Range")
local player = game.Players.LocalPlayer.Character

part.Anchored = true
part.CFrame = player.HumanoidRootPart.CFrame

local function updatePartPosition()
part.CFrame = player.HumanoidRootPart.CFrame * CFrame.new(0, -3.1, 0)
end

updatePartPosition()

game:GetService("RunService").Heartbeat:Connect(updatePartPosition)

part.Touched:Connect(function(hit)
if hit:IsA("Part") and hit.Name:match("Cookie_1") then
hit:Destroy()
end
end)

#

this is the one i worked till i got answear

umbral swan
#
    part.CFrame = player.HumanoidRootPart.CFrame * CFrame.new(0, -3.1, 0)
end``` whats the point of this? are you trying to make an unobtainable cookie?
cursive urchin
#

no

#

my point is

#

when you walk over cookie

umbral swan
#

continue

cursive urchin
#

it destroys

#

and gives you

#

+1 cookie on leaderstats

umbral swan
#

okay

unique ingot
#
local cookie = game.Workspace.Cookie

cookie.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.leaderstats.Cookies.Value += 1
cookie:Destroy()
end
end)
#

This

#

Does what u want

umbral swan
#

@cursive urchin do you have multiple cookies?

unique ingot
cursive urchin
#

ty

unique ingot
#

Pls help me learn coding @umbral swan

unique ingot
cursive urchin
#

@unique ingot

unique ingot
#

Show script ss

cursive urchin
#

humanoid

#

was wrong

#

it should be

#

"humanoid"

unique ingot
#

No

#

It shouldnt

cursive urchin
#

i changed

#

it

unique ingot
#

But since im on mobile

cursive urchin
#

and it isnt

#

problem anymore

unique ingot
#

It shouldnt work

cursive urchin
#

but now

#

idk why this happenes

unique ingot
#

Because “Cookie” isnt a valid member of workspace

#

🙂

#

It means

#

That it has an incorrect path

#

Or that cookie isnt loaded yet

cursive urchin
#

so how do i find its path?

unique ingot
#

its the correct path

#

It hasnt loaded

#

game.Workspace:WaitForChild(“Cookie”)

#

Again

#

Remember to change “ to the pc symbol

#

Since “ is not supported from mobile dc

cursive urchin
#

ok

#

k

cursive urchin
umbral swan
unique ingot
#

1st line where i define cariable

#

Variable*

cursive urchin
#

k

#

so

#

instead of first line

#

i add

#

game.Workspace:WaitForChild(“Cookie”)?

unique ingot
#

no

cursive urchin
#

then

unique ingot
#

After the “=“ u add it

cursive urchin
#

ok

unique ingot
#

local cookie = ADD HERE

#

YES

cursive urchin
#

sorry

#

i forgot

#

you cant use

#

""

unique ingot
#

I cant

cursive urchin
#

ok

#

should work

#

now

unique ingot
#

no

unique ingot
cursive urchin
#

i did

#

change

unique ingot
#

Ok

#

Try

cursive urchin
#

it works

#

on 1 cookie

#

ony

#

only

#

it cant pick up these

unique ingot
#

Well its because only cookie has been scripted

umbral swan
unique ingot
#

instead of doing what we just did make a new script inside the cookie. Make sure its a server script

unique ingot
#

I figured

cursive urchin
umbral swan
#

you can use a for loop for each individual cookie

unique ingot
umbral swan
#

how so

cursive urchin
#

guys

#

pls

unique ingot
#

And then change variable we just changed to this

sleek sandalBOT
#

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

cursive urchin
#

make agreement

unique ingot
#

script.Parent

umbral swan
unique ingot
#

🙂

umbral swan
#

okay do it lets see what works best

cursive urchin
#

ok

cursive urchin
#

this

#

this*

#

into

#

script.Parent this

unique ingot
umbral swan
unique ingot
#

And then

cursive urchin
#

ok

#

what now

unique ingot
#

Once done that

#

Have u made the scripts inside cookie?

#

inside every cookie paste the script

#

In a server script

cursive urchin
#

whut

unique ingot
#

Ok so

#

In the explorer

#

Find ur cookie instance

cursive urchin
unique ingot
#

Hover over it and click the ‘+’ button

cursive urchin
#

there is 1 cookie

unique ingot
#

Then search ‘script’ and add the white one.

cursive urchin
unique ingot
#

Then

cursive urchin
#

this is where script is

unique ingot
#

Open script

#

And paste script

#

We made

cursive urchin
#

i did

unique ingot
#

🙂

cursive urchin
#

brotha

#

you making this

#

so confusing

#

like

#

cant you just

#

make one script

#

that works for every cookie

unique ingot
#

Its so simple!!

cursive urchin
#

without needing

#

to paste in every cookie

umbral swan
# cursive urchin

you dont need to answer this now but is the range part there to detect when cookie is touched

unique ingot
#

Ok do what @umbral swan says

cursive urchin
#

my friend made this

#

part

#

i came to script just

unique ingot
#

That explains the updatePartPosition stuff

umbral swan
cursive urchin
#

yeah

#

when u walk/touch the cookie with player it destroys and gives you +1 cookie in leaderstats

unique ingot
#

Yep

cursive urchin
#

my friend made a part under character

unique ingot
#

I think i know how to do 1 script for all know

#

But i would need to search some shit up

cursive urchin
#

tho i dont think

#

that we need to changed anything

#

it works

unique ingot
#

Its actually pretty smart with the range stuff

cursive urchin
#

it works

unique ingot
#

But u didnt listen

#

Like 1 in every cookie

cursive urchin
#

bc its confusking

unique ingot
#

Works

#

But u wanted 1 script

#

And that explains the range stuff

cursive urchin
#

i think

#

my friend

#

maybe

unique ingot
#

Its like a hitbox for player

cursive urchin
#

made

#

hitbox under characted

unique ingot
#

He pretty clever

cursive urchin
#

made 1 cookie

#

am i right?

#

and that range?

#

it

unique ingot
#

U are right

cursive urchin
#

like if you that hitbox come near it collect?

unique ingot
#

Yep

cursive urchin
#

ok

#

now i need to see how to make respawn script for it

unique ingot
#

Uhm

#

Now it might be better to do ur friends solution

cursive urchin
#

what ?

unique ingot
#

So uhm here lemme write a script that works and spawns multiple cookies

cursive urchin
#

ok lets try that

#

whut

#

fr

umbral swan
#

okay simple.
just do this:

  1. make a seperate folder and name it for the cookies so its not an eyesore and easy to locate all of them
  2. put all cookies in there
  3. create an attribute in each cookie called "Collected", make sure its false
  4. create a script in serverscriptservice
  5. paste this:
    cookie.Touched:Connect(function(otherPart)
        if otherPart.Parent:FindFirstChildOfClass("Humanoid") then
            local char = otherPart.Parent
            local plr = game:GetService("Players"):GetPlayerFromCharacter(char)
            
            if cookie:GetAttribute("Collected") == true then return end

            cookie:Destroy()
            plr:WaitForChild("leaderstats"):WaitForChild("Cookies").Value += 1
            print(plr:WaitForChild("leaderstats"):WaitForChild("Cookies").Value)
        end
    end)
end```
#

should look something like that

umbral swan
#

and btw delete that range shit lol

cursive urchin
#

i am so confused

umbral swan
#

blud 💀

cursive urchin
#

wtf did this guy sent now

unique ingot
#

Dont do what he says

#

Is waaay simpler

#

Mate

#

Why u gotta be so confusing

#

Pls dont destroy anything

cursive urchin
#

brotha

unique ingot
#

BRUH I JUST DELETED MY ENTIRE SCRIPT AAAAH

cursive urchin
#

my friend

#

want range

unique ingot
#

2 sec

cursive urchin
#

bc he want to make upgrades

unique ingot
#

Brb

cursive urchin
#

for it to become

#

larger

#

no point in deleting it

umbral swan
unique ingot
#

Ye

umbral swan
unique ingot
#

Dont do that

#

Its because u said u had genious solution

#

Its way simpler than this

cursive urchin
#

leave chat

#

bro

unique ingot
#

I cant

#

Im on phone

#

Jso1 pls lemme cook pls

umbral swan
#

ik what im talking ab

cursive urchin
#

bro

#

what help

#

they alredy

#

helping me fore

#

like 30+ minutes

#

i fixed that error

unique ingot
#

@cursive urchin

cursive urchin
#

yes

unique ingot
#

Send script

#

Ols

#

Pls

cursive urchin
#

what script

#

no

#

why would i

sleek sandalBOT
#

studio** You are now Level 6! **studio

umbral swan
cursive urchin
#

can someone help with fixing a script .

unique ingot
#

Dont pls

#

Its so much simoler

#

Simpler

cursive urchin
#

bro

#

agreee

#

alredyyyy

unique ingot
#

Pls send script @cursive urchin

cursive urchin
#

local cookie = script.Parent

cookie.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.leaderstats.Cookies.Value += 1
cookie:Destroy()
end
end)

#

this

unique ingot
#

Leave chat rn pls

cursive urchin
#

script

#

that youwant

#

is it

unique ingot
#

I cab do this all fine

umbral swan
#

@unique ingot you were asking me for help and now you are trying to sabotage me helping someone? you wanted to paste a script into every single cookie which would be much harder

cursive urchin
#

ok

#

OK

#

STOP

#

JUST STOP

#

i made

umbral swan
#

@unique ingot the agreement was if ur thing didnt work then he would ask me for help and ur making them confused

cursive urchin
#

fixed*

#

My friend

#

wants for range to show

#

bc it will be upgradable

umbral swan
#

there will be performance issues and will get confusing

cursive urchin
#

i want

#

to have range

#

and when cookie

#

in range

#

it get picked up

#

and on leaderstats it gives +1

umbral swan
#

i mean preference tbhh

sleek sandalBOT
#

studio** You are now Level 5! **studio

cursive urchin
#

bro typing respawn script

#

on phone

sleek sandalBOT
#

studio** You are now Level 12! **studio

cursive urchin
#

thats why it takes so long

umbral swan
cursive urchin
#

yeah

#

something like psx

umbral swan
#

lerp the cookie to hrp

cursive urchin
#

when in range it gets picked up

#

wha

#

lerp, hrp?

umbral swan
cursive urchin
#

i want all help i can get

#

but you guys need to make agreement

unique ingot
#

local cookie = game.Workspace.Assets:WaitForChild("Cookie")
local hitbox = cookie.Parent.Range

while true do
hitbox.Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position * Vector3.new(0, 3.1, 0)
task.wait(.1)
end

hitbox.Touched:Connect(function(hit)
if hit.Name == cookie.Name then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.leaderstats.Cookies.Value += 1
cookie.Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position * Vector3.new(10, 0, 10)
end
end)

#

Might do the trick

#

Make it a local script inside starter player scripts again

#

As it was when we started

#

Uhm

#

No

#

I forgot something

cursive urchin
#

bruh

unique ingot
#

Here

#

Now

#

Should work

#

350 msgs here 💀

#

It does not

#

Since i forgot the core part of script

#

Gimme sec

cursive urchin
unique ingot
#

Now 🙂

#

No

#

This is the same scripr

#

Paste this entire script inside “lines i want to work”

#

Instead of anything in there

unique ingot
cursive urchin
#

ok

unique ingot
#

Also can i see the script that clones the cookies and places them down?

#

Just an SS

cursive urchin
#

yeah i think

#

ima let my friend do it

#

bc

#

the scripts you sending

#

is gona make me a problem later

#

bc i need range

#

not humanoid

unique ingot
#

What problem

cursive urchin
#

and he

#

alredy fixing it

#

so closing this now

unique ingot
#

Wdym

#

Stop

#

Dont

#

Wait

#

I dont understand what u mean

#

I need range not humanoid??

#

@cursive urchin

#

What is the problem?

#

Im sure its solvable

#

Cuz this is as simple as it gets

cursive urchin
#

brotha

#

i need rangeeeee

#

the point

#

i talked

unique ingot
#

Wdymmmm

cursive urchin
#

on start

#

that my friend i do

#

that

#

WHEN IN RANGE PICK UP

#

its simple not math

#

to read

unique ingot
#

It should be doing that!!

#

I dont understand what u want that it doesnt do 😭

cursive urchin
#

its not

#

the script you sent

#

me

#

deleted the range

unique ingot
#

No it didnt

#

I did not say hitbox:Destroy() at any point

#

Idk what ur talking about

cursive urchin
#

thats why i asked to fix

#

brotha

#

no point in saying when you dont ge it

unique ingot
#

If u wanna be dum and not listen alright go ahead i dont care that i just wasted 39 minutes of my life to help some random stranger to get accused of doing stuff i didnt do

cursive urchin
#

broooo

#

i asked to fix

#

there was lines

unique ingot
#

Ok

cursive urchin
#

showing range

unique ingot
#

I see what u mean

cursive urchin
#

range was deleted

unique ingot
#

Wdymmmm

cursive urchin
#

we want every player to have range

unique ingot
#

Yes

#

Thats an issue

cursive urchin
#

this

#

thats not an issue

#

we want every player to have range

unique ingot
#

But fairky simple

#

Add

cursive urchin
#

if that range

unique ingot
#

:Clone()

cursive urchin
#

come in contant with cookie

unique ingot
#

And done

cursive urchin
#

then pick it up

unique ingot
#

Yes

#

I did that

#

But

#

I forgot

#

The “:Clone()” part

cursive urchin
#

il let him do range part

#

i dont need help anymore

unique ingot
#

local cookie = game.Workspace.Assets:WaitForChild("Cookie")
local hitbox = cookie.Parent.Range:Clone()

while true do
hitbox.Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position * Vector3.new(0, 3.1, 0)
task.wait(.1)
end

hitbox.Touched:Connect(function(hit)
if hit.Name == cookie.Name then
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
plr.leaderstats.Cookies.Value += 1
cookie.Position = game.Players.LocalPlayer.Character.HumanoidRootPart.Position * Vector3.new(10, 0, 10)
end
end)

#

Its done

cursive urchin
#

what with this?

unique ingot
unique ingot
#

Would u pls test it?

cursive urchin
#

and where that 'Script"

#

put it

unique ingot
#

Wdym

#

Put it in a local script in starter player script

#

And everything should work

cursive urchin
#

in it is respawn script?

unique ingot
#

Its the 1 script u need for all u wanted done in this entire conversation

cursive urchin
#

ok

unique ingot
#

It makes the hitbox follow the player, detects if the hitbox hits a cookie and if it does it destroys the cookie and teleports it to a new random position.

#

Also adds +1 to the leaderstats

cursive urchin
#

ok

#

as i see

#

it doesnt work

unique ingot
unique ingot
cursive urchin
#

maybe

#

i dont think so

#

what do you think

#

🗿

unique ingot
#

Its because u havent made a leaderstats system yet

cursive urchin
#

?

unique ingot
#

I didnt know that

#

Well

#

Ok lets do that

cursive urchin
#

i did

unique ingot
#

Lemme see

#

The script

cursive urchin
#

you typed

#

leaderstats but name is LeaderStats

#

so its prob that

#

nope

#

nothing here

unique ingot
#

its not the script name

#

Lemme see the script

#

In serverscriptservice

#

Called leaderstats

#

Lemme see whats inside it

cursive urchin
#

i am in test place

unique ingot
#

Yes

#

Just send me the script

unique ingot
#

LEMME SEE WHAT CODE IS INSIDE IT

cursive urchin
#

local DataStoreService = game:GetService("DataStoreService")
local playerDataStore = DataStoreService:GetDataStore("PlayerDataStore") -- Substitua "PlayerDataStore" pelo nome da sua DataStore

local function salvarDadosJogador(jogador, dados)
pcall(function()
playerDataStore:SetAsync(jogador.UserId, dados)
end)
end

local function carregarDadosJogador(jogador)
local success, data = pcall(function()
return playerDataStore:GetAsync(jogador.UserId)
end)
if success then
return data or {cookies = 0}
else
return {cookies = 0}
end
end

local function atualizarLeaderstats(jogador, cookies)
local leaderstats = jogador:FindFirstChild("leaderstats")
if leaderstats then
local cookieStat = leaderstats:FindFirstChild("Cookies")
if cookieStat then
cookieStat.Value = cookies
end
end
end

game.Players.PlayerAdded:Connect(function(player)
local dadosJogador = carregarDadosJogador(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local cookies = Instance.new("IntValue")
cookies.Name = "Cookies"
cookies.Value = dadosJogador.cookies
cookies.Parent = leaderstats

player.CharacterAdded:Connect(function(character)
    atualizarLeaderstats(player, dadosJogador.cookies)
end)

end)

game.Players.PlayerRemoving:Connect(function(player)
local dadosJogador = {
cookies = player.leaderstats.Cookies.Value
}
salvarDadosJogador(player, dadosJogador)
end)

cursive urchin
#

my friend

#

why?

unique ingot
#

I dont see anything adding the leaderstats

#

And why it gotta be so complicated?

cursive urchin
#

it worked

#

idk

unique ingot
#

Datastore is simple

cursive urchin
#

bro dont ask me

unique ingot
#

Kk

#

Do u have any leaderstat working?

cursive urchin
#

yeah

#

in my other game

#

gona get it now

unique ingot
#

U fr?

cursive urchin
#

?

#

what

#

i think i have it

#

i have this

#

good news

#

when i made for rebirths and coins

unique ingot
#

Ok

#

So now

#

When u join

#

Are there a folder inside the player

cursive urchin
#

game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Parent = leaderstats

local rebirths = Instance.new("IntValue")
rebirths.Name = "Rebirths"
rebirths.Parent = leaderstats

end)

#

local dataStore = game:GetService("DataStoreService"):GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(plr)
wait()
local plrid = "id_"..plr.UserId
local save1 = plr.leaderstats.Coins
local save2 = plr.leaderstats.Rebirth

local GetSaved = dataStore:GetAsync(plrid)
if GetSaved then
    save1.Value = GetSaved[1]
    save2.Value = GetSaved[2]
else
    local NumberForSaving = {save1.Value, save2.Value}
    dataStore:GetAsync(plrid,NumberForSaving)
end 

end)

game.Players.PlayerRemoving:Connect(function(plrid)
dataStore:SetAsync("id_"..userID{plr.leaderstats.Coins.Value, plr.leaderstats.Rebirths.Value})
end)

unique ingot
#

Called leaderstats

unique ingot
#

I have no idea about datastore

#

And it rly doesnt matter either

#

But the leaderstat stuff now should work

#

Just change coin name to “Cookie@

cursive urchin
cursive urchin
unique ingot
#

Uhm

#

Thats not good

#

There should be a folder

cursive urchin
#

in my old game it works

#

tho it has teams

#

xd

unique ingot
#

Yea

cursive urchin
#

but that doesnt matter

unique ingot
#

Nope

#

Because

#

We need to work now

cursive urchin
#

ima copy this

#

to my friend game

unique ingot
#

Why does it not work?

#

Did u make the scripts inside the game

cursive urchin
#

idk

#

i forgot

unique ingot
#

So

unique ingot
cursive urchin
#

yeah

cursive urchin
unique ingot
#

Make these scripts inside the cookie game

#

So that it adds it when player joins cookie game

#

It adds leaderstats

cursive urchin
#

whut

unique ingot
#

Add the scripts in the cookie game

#

The scripts that makes lesderstats

cursive urchin
#

ok

#

inplented

#

datastore

#

and leaderstats

unique ingot
#

Ok

cursive urchin
#

now going to shower

unique ingot
#

Try now

cursive urchin
#

but it doesnt work

#

gg

unique ingot
#

Wdym

#

Error?

cursive urchin
unique ingot
#

Well

cursive urchin
#

fixing

unique ingot
#

Thats on u it aint my scripts positng so many errors.

cursive urchin
#

ik

#

fixing it

unique ingot
#

Kk

#

Nice

#

Try it now

cursive urchin
#

idk what my friend

#

doing

#

he doing something with range

#

so it does not pick up

#

ima go shower

unique ingot
#

Ok

#

Il dead inside because of this “friend” that destroys my scripts

cursive urchin
#

nvm

#

it works

#

lb

#

and pick up

#

but it does not

#

showe on lb

unique ingot
#

Errors?

cursive urchin
#

gona see

#

tihs is for error

#

unable

#

this for second

unique ingot
#

Line 5 add a .Value at the end

#

That fix 1st error

cursive urchin
#

k

unique ingot
#

And the other error is because

cursive urchin
unique ingot
#

U have to change “userID” to plrid

cursive urchin
#

not 5

unique ingot
#

Ok remove .Value

cursive urchin
#

k

unique ingot
#

At end of line 5

cursive urchin
#

k

unique ingot
#

And the last error is because

#

plr has not been defined

#

Ok

#

Last function

#

Remove the “id” in the argument

#

And then

#

write this line: local userID = plr.PlayerId

cursive urchin
#

can you specify

#

what line

unique ingot
#

Ok

cursive urchin
#

i remove

#

this "id"

unique ingot
#

game.Players.PlayerRemoving:Connect(function(plr)
local userID = plr.PlayerId

#

No

#

And then continue with tve :SetAsync u git already

cursive urchin
#

i delete this and copy what u sent?

unique ingot
#

Delete line 17

#

And paste

#

What i said

cursive urchin
#

ok

#

?

unique ingot
#

Alr

#

Uhm

#

After local instead lf userID write plrid

#

And it should work?

cursive urchin
unique ingot
#

Yes

cursive urchin
#

ok

#

still some error

unique ingot
#

Ik

cursive urchin
#

my friend

#

did something

#

and cookies dont spawn anymore

#

and he dont know what he did

#

nvm he found out

unique ingot
#

Ok

#

Can u just ignore this rq, does the script i provided work now?

cursive urchin
#

it doesnt have error

#

so yes

unique ingot
#

Its not equal to it working, does it pick cookies up and add to leaderboard and tp cookie to another posiion?

cursive urchin
#

i just said he moved it accidentaly

#

wait a sec

#

@unique ingot

unique ingot
#

Fr

#

Cookie

#

Not C

#

Line 3

#

Needs to be “Cookie”

#

Not “C”

cursive urchin
#

k

#

wait

#

what

#

Cookie

#

not c/

#

ohh

#

there are two errors

unique ingot
#

Uhhhh

#

Maan

#

Im tired

cursive urchin
#

i am too

unique ingot
#

I cant do this no more

#

Im out

cursive urchin
#

come on

unique ingot
#

Good night

cursive urchin
#

bruh

umbral swan
#

2 and 1/2 hours on this thas crazy