#helping a newbie

1 messages · Page 1 of 1 (latest)

mossy pier
#

hello, im pretty new to scripting and im trying to make a little clicker game right now to learn a bit more, although i ran into a problem that i dont know how to really fix. i have this script, which is a LocalScript inside StarterPlayerScripts but increasing the players stats is not working out, how would i solve this problem else? thanks in advance :)

local itemPrice = {
    Id1 = 10,
    Id2 = 100,
    Id3 = 100
}

for _, button in InShopMenu:GetDescendants() do
    if button:IsA("TextButton") then
        button.MouseButton1Click:Connect(function()
            local itemId = button:GetAttribute("ItemId")
            local playerClicks = localPlayer:WaitForChild("leaderstats"):WaitForChild("Clicks")
            
            if playerClicks.Value >= itemPrice[itemId] then
                playerClicks.Value -= itemPrice[itemId]
                kaChing:Play()
                
                if itemId == "Id1" then
                    local playerClickPower = localPlayer:WaitForChild("leaderstats"):WaitForChild("ClickPower")
                    playerClickPower.Value += 1
                end
            else
                notEnoughClicksSound:Play()
            end
            

            
        end)
    end
end
mighty geode
#

first of all id recommend using .Activated instead of .MouseButton1Click

#

its not a big deal

#

but i assume in the future you might want mobile players of console players

mossy pier
#

oh okay true thank you, it would be a different apporach to set up the buttons for console players in general though no? it has to cycle between the buttons if they push the stick in a direction, or does roblox do that for you?

torn mistBOT
#

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

mighty geode
#

roblox should do that for you

#

but if its MouseButton1Click, it only listens for mouse presses

mossy pier
#

for my code: i know i can do something with remoteevents to send it maybe to a non local script? but im not really aware what i could do, im really trying to make this without any ChatGPT so i actually learn but i wouldnt know how to proceed :(

mighty geode
#

so whats your goal

#

and what doesnt work

mossy pier
#

this right now is behaving like a local system where when i purchase something, after updating my "money" it also forgets that there was something that i bought as if it wasnt saved on the server (??)

#

my goal is to just increase the ClickValue, which would make that i get more "Click" per action so i can upgrade basically, but that is also not being accounted for in my different clicking script

mighty geode
#

so, when you "buy" id1 your clickpower or whatever increases?

mossy pier
#

yes exactly

mighty geode
#

okay so

snow quiver
#

Since you created a leaderstats on Server, you can't update server leaderstats with a local script. It only change for Client visual, but in server efffects, nothing happens.

mossy pier
#

which is Clicks = ClickableValue + ClickPower - 1

mighty geode
#

is it?

#

@mossy pier

mossy pier
#

no its local

mighty geode
#

yeah thats your issue

snow quiver
mighty geode
#

gotta do this on the server

mossy pier
#

okay thats what i thought thanks, so best fix would be with remote evenet?

mighty geode
#


remoteEvent:FireServer()
mossy pier
#

okay just for my info, i cant handle any sorts of leaderboard information on a localscript, i send all to a serverscript via remoteevent and handle it there?

bitter brook
#

right

mighty geode
mossy pier
#

maybe some1 knows some good video about remoteEvents? :) or even some "scripting teaching"? id pay for that also if it pays off

bitter brook
#

Devking

mighty geode
#

its pretty simple tbh

#

all you need to know

#

is

bitter brook
#

client server links

mighty geode
#

FireServer()
FireClient()

OnServerEvent
OnClientEvent

#

FireServer -> OnServerEvent

#

FireClient -> OnClientEvent

mossy pier
#

https://www.youtube.com/watch?v=GwhPXyYKkwU
this is 5 years old but im guessing nothing really changed in luau?

Advanced Roblox Scripting Tutorial #8 - Remote Events & Remote Functions (Beginner to Pro 2019)

Hey guys! Welcome back to another roblox scripting tutorial and guys in today's tutorial I am going to be teaching you about remote events and remote functions. Now this is a pretty complex topic so if you are confused don't feel bad I was at first a...

▶ Play video
mighty geode
#

yeah

mossy pier
#

okay great, thanks guys :) what about the teaching scripting part, does maybe someone know anything about that? i dont mind spending money if i learn something / or would u recommend just sticking to spamming videos

snow quiver
#
--== Local script ==--
local RS = game:GetService("ReplicatedStorage")
local event = RS.RemoteEvent

event.FireServer("Hey, i want to upgrade")

--== Server ==--
local RS = game:GetService("ReplicatedStorage")
local event = RS.RemoteEvent

event.OnServerEvent():Connect(function(player,message)
  print("Look, im on Server, and "..player.Name.." Want to ask:\n"..message)
end)
mighty geode
#

you have many options

#

id recommend dev docs

#

roblox docs

#

if you havent used it yet

#

this is incredibly useful

mossy pier
#

yea i looked at those docs often but my problem was that english not being my first or second language i kinda dont understand something and then the whole section makes no sense to me, thats why i thought talking to someone would speed up the learning

mighty geode
#

so

#
gui.Activated:Connect(function()
   Event:FireServer()

end)
#

😁

bitter brook
#

but its like by scripting experience that you'll udnerstand keywords such as callbacks and stuff

mighty geode
snow quiver
#

Btw i don't want to overhelm you, but this is kinda a bad idea:

local itemPrice = {
    Id1 = 10,
    Id2 = 100,
    Id3 = 100
}

local itemId = button:GetAttribute("ItemId")
if playerClicks.Value >= itemPrice[itemId] then

If u keep this on client side, Player can abusing it. ("Making cheaper")

I understand, youre newbie. i don't want to overhelm, but just a tips.
Its always a good way, to store all in Server side, and pass Price infos to client with RemoteEvent also 🙂

mossy pier
#

event.FireServer("Hey, i want to upgrade")

event.OnServerEvent():Connect(function(player,message)

is the player auto assigned as a argument, just to see from who it came?

snow quiver
#

Yes.

bitter brook
#

the player arg will always be there

mighty geode
mossy pier
#

im suprised by the amount of help, thanks a lot :)

mossy pier
#

this is something which chatGPT recommended, although im done using that sh*t after my first game where i spend a bit of time stopped working alltogether hahaha

mighty geode
#

the reason for that is if you store everything on the client, exploiters can abuse that. so generally when possible you should store things on the server

bitter brook
#

also

torn mistBOT
#

studio** You are now Level 9! **studio

bitter brook
#

read this

#

it might help also with different subjects it explains quite well

mossy pier
#

okay thanks, got a full day of reading ahead of me now lol

torn mistBOT
#

studio** You are now Level 3! **studio

mighty geode
#

hey you got it man

#

slow progress, but totally worth it

#

if you have any issues

#

ping any one of us

mossy pier
#

hahaha alright thanks a lot

bitter brook
#

anyone knows when script ranking will be opening back tho?

mighty geode
#

no clue

bitter brook
#

im tired of s1 rank 🙏

mighty geode
#

i wanna get ranked man

mossy pier
#

i thought of completly different help when i saw this, u guys changed my midn tho thanks again

mighty geode
#

😭

mossy pier
#

oh wait thats you hahahaha

bitter brook
#

yea bro flag help him

#

thats you bro xd

mighty geode
#

thats not me bro

bitter brook
#

help him

mighty geode
#

i swear

#

nah nah

#

thats not me

#

lol

bitter brook
#

it is ;-;

mighty geode
#

i saw massive

#

and i couldnt help myself

snow quiver
#

I mean, the guy didn't even show the code. 🙂 xD

mighty geode
#

i shouldve been a mind reader

#

my bad

bitter brook
#

;-;;;

mighty geode
#

😭

#

49 whole robux

mossy pier
#

half of his pocket money, its a big investment for him

mighty geode
#

btw raptorus i only started scripting properly 4 or so months ago so you should pick it up quite quick. id recommend watch the whole devking begginner playlist

#

then the advanced one

hollow pier
mighty geode
#

hm

#

thanks

#

its work just as well for me and less to type, still useful though

mossy pier
#

@mighty geode @bitter brook what else do you guys think helped you a lot to script? was it just yt/the docs or is there something more

bitter brook
#

devking helped me alot

#

also

mighty geode
bitter brook
#

the site i sent you with coroutines

#

and alsoooo game reviews for making games

mighty geode
bitter brook
mighty geode
#

devking gave me a basis, ai helped me develop on that and roblox docs filled my gaps of knowledge and showed me it in practice