#can someone help with fixing a script .
645 messages · Page 1 of 1 (latest)
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
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?
continue
okay
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
@cursive urchin do you have multiple cookies?
Why u need to know that?
ty
Pls help me learn coding @umbral swan
Np
Show script ss
But since im on mobile
It shouldnt work
Because “Cookie” isnt a valid member of workspace
🙂
It means
That it has an incorrect path
Or that cookie isnt loaded yet
so how do i find its path?
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
where do i inplent this
look at what the error actually says
no
then
After the “=“ u add it
I cant
no
Cuz u havent changed here
Well its because only cookie has been scripted
you see thats why i needed to know that
instead of doing what we just did make a new script inside the cookie. Make sure its a server script
yes didnt see message
you can use a for loop for each individual cookie
That wont be very effective
how so
Do this
And then change variable we just changed to this
** You are now Level 16! **
make agreement
script.Parent
so you want to create as many scripts as there are cookies?
🙂
okay do it lets see what works best
ok
script.Parent
it will work i just mean in terms of convinience incase you want to add more cookies in the future.
And then
Yea
Once done that
Have u made the scripts inside cookie?
inside every cookie paste the script
In a server script
whut
Hover over it and click the ‘+’ button
there is 1 cookie
Then search ‘script’ and add the white one.
Then
this is where script is
i did
brotha
you making this
so confusing
like
cant you just
make one script
that works for every cookie
Its so simple!!
you dont need to answer this now but is the range part there to detect when cookie is touched
Ok do what @umbral swan says
idk
my friend made this
part
i came to script just
I think so
That explains the updatePartPosition stuff
uh ok so you want the cookie counter to go up by 1 when cookie is touched right? and destroy the cookie after
yeah
when u walk/touch the cookie with player it destroys and gives you +1 cookie in leaderstats
Yep
my friend made a part under character
I think i know how to do 1 script for all know
But i would need to search some shit up
Its actually pretty smart with the range stuff
it works
Ofc thats what i told u
But u didnt listen
Like 1 in every cookie
bc its confusking
Its like a hitbox for player
He pretty clever
U are right
like if you that hitbox come near it collect?
Yep
what ?
So uhm here lemme write a script that works and spawns multiple cookies
okay simple.
just do this:
- make a seperate folder and name it for the cookies so its not an eyesore and easy to locate all of them
- put all cookies in there
- create an attribute in each cookie called "Collected", make sure its false
- create a script in serverscriptservice
- 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
and the attribute is there so that incase the player touched it again somehow
and btw delete that range shit lol
i am so confused
blud 💀
wtf did this guy sent now
Dont do what he says
Is waaay simpler
Mate
Why u gotta be so confusing
Pls dont destroy anything
brotha
BRUH I JUST DELETED MY ENTIRE SCRIPT AAAAH
2 sec
bc he want to make upgrades
Brb
huh? r u talking ab me?
Ye
what
trust me read the instructions its not as hard as u think. ur phone might make it look like a longet list
ik what im talking ab
bro
what help
they alredy
helping me fore
like 30+ minutes
i fixed that error
@cursive urchin
yes
** You are now Level 6! **
@cursive urchin my man breatheeeeeee. just follow this if it works then good if it doesnt then idk but it works trust me.
can someone help with fixing a script .
Pls send script @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
Leave chat rn pls
I cab do this all fine
@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
@unique ingot the agreement was if ur thing didnt work then he would ask me for help and ur making them confused
ok can you please tell me how did u fix it
there will be performance issues and will get confusing
i want
to have range
and when cookie
in range
it get picked up
and on leaderstats it gives +1
i mean preference tbhh
** You are now Level 5! **
** You are now Level 12! **
thats why it takes so long
so smth like pet simulator?
lerp the cookie to hrp
im going to leave this to @unique ingot ig he knows more than me
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
bruh
Here
Now
Should work
350 msgs here 💀
It does not
Since i forgot the core part of script
Gimme sec
Now 🙂
No
This is the same scripr
Paste this entire script inside “lines i want to work”
Instead of anything in there
Delete this script
ok
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
What problem
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
Wdymmmm
on start
that my friend i do
that
WHEN IN RANGE PICK UP
its simple not math
to read
No it didnt
I did not say hitbox:Destroy() at any point
Idk what ur talking about
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
Ok
showing range
I see what u mean
range was deleted
Wdymmmm
we want every player to have range
if that range
:Clone()
come in contant with cookie
And done
then pick it up
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
what with this?
Alright no problem for helping thanks for thanking me!
The script that works and does what u want
Would u pls test it?
Wdym
Put it in a local script in starter player script
And everything should work
in it is respawn script?
Its the 1 script u need for all u wanted done in this entire conversation
ok
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
Wow
Any error in output?
Its because u havent made a leaderstats system yet
?
you typed
leaderstats but name is LeaderStats
so its prob that
nope
nothing here
its not the script name
Lemme see the script
In serverscriptservice
Called leaderstats
Lemme see whats inside it
i am in test place
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)
Who wrote this?
Datastore is simple
bro dont ask me
U fr?
?
what
i think i have it
i have this
good news
when i made for rebirths and coins
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)
Called leaderstats
This works
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@
ik
Yea
but that doesnt matter
So
Is these script inside the cookie game?
And these inside?
this is inside script leaderstats
Make these scripts inside the cookie game
So that it adds it when player joins cookie game
It adds leaderstats
whut
Im tired of this
Add the scripts in the cookie game
The scripts that makes lesderstats
Ok
now going to shower
Try now
Well
fixing
Thats on u it aint my scripts positng so many errors.
idk what my friend
doing
he doing something with range
so it does not pick up
ima go shower
Errors?
k
And the other error is because
this error is line 12
U have to change “userID” to plrid
not 5
Ok remove .Value
k
At end of line 5
k
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
Ok
game.Players.PlayerRemoving:Connect(function(plr)
local userID = plr.PlayerId
No
And then continue with tve :SetAsync u git already
i delete this and copy what u sent?
?
Yes
Ik
my friend
did something
and cookies dont spawn anymore
and he dont know what he did
nvm he found out
Its not equal to it working, does it pick cookies up and add to leaderboard and tp cookie to another posiion?
i am too
come on
Good night
bruh
2 and 1/2 hours on this thas crazy