#Scripting help pls
1 messages · Page 1 of 1 (latest)
what time
22:24
aint no way vro 🥀
Bru
its 4am and im barely tired
How i feel rn
Yeay
local CoinButton = script.parent
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvent = ReplicatedStorage.RemoteEvent
local MouseClick = game.SoundService.MouseClick
local CoinLabel = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.CoinLabel
local Coins = 0
CoinButton.Activated:Connect(function()
Coins = Coins + 1
RemoteEvent:FireServer(Coins)
MouseClick:Play()
CoinLabel.Text = Coins
end)
np
thats the coins
local StrengthButton = script.parent
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvent = ReplicatedStorage.RemoteEvent
local MouseClick = game.SoundService.MouseClick
local StrengthLabel = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.StrengthLabel
local Strength = 0
StrengthButton.Activated:Connect(function()
Strength = Strength + 1
RemoteEvent:FireServer(Strength)
MouseClick:Play()
StrengthLabel.Text = Strength
end)
this is strength
leaderstats and the gui numbers arent the same and i got no idea why
Instead of “activated” try “MouseButton1Click”
activated should be fine
theres more problems
show the leaderstats script, especially if this is the script that works as intended
yea activated wasnt it
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 0
Coins.Parent = leaderstats
Strength = Instance.new("IntValue")
Strength.Name = "Strength"
Strength.Value = 0
Strength.Parent = leaderstats
end)
RemoteEvent.OnServerEvent:Connect(function(Player, Coins)
Player.leaderstats.Coins.Value = Coins
end)
RemoteEvent.OnServerEvent:Connect(function(Player, Strength)
Player.leaderstats.Strength.Value = Strength
end)
i know im doing smth supid and obvious i just have no idea what
the problem is how you are handling the events
you are not differentiating between adding the strenght and coins
(hes a professional, im not)
alrr
im more noob than you trust
I dont know how to disable backpack
in the leaderstats?
i thought i did
with the
RemoteEvent.OnServerEvent:Connect(function(Player, Strength)
Player.leaderstats.Strength.Value = Strength
what am i missing?
core gui heh.
yes in the leaderstats, either you need two different remote events (one for strength, and one for coins). or you need to use the arguments you passed in your one remote event in an if statement to for the script to know what to add
fire the client in the server script to update the text to the current value of whatever
basically the fix im suggesting is:
- in your leaderstats script get rid of one of your remote event functions
- change the name of the parameter in the if statement to something like makes more sense, like "stat"
oh crap hold up the arguement is a num value
nvm forget what i said just use two different remote events
one for coins one for strength
when i made two remote events
lol
the strength button didnt even work
make sure they have different names
yea i did
try it again and we will fix that
alr ill try it again
** You are now Level 6! **
nvm
okay so now the strength button doesnt even update leaderstats
but the gui still works
show explorer rq
show code + explorer
show leaderstats code
sick try it then
LMAO
ARE WE DEADASS
ITS CUZ I DIDNT WRITE THIS SHIT
local RemoteEvent2 = game.ReplicatedStorage.RemoteEvent2
actually gonna kms bro
Show whole starterGui
its working now jesus christ
certified scripting moment
alr
Bro helped us 🥀
no need if it works
Dont we all

I genuinely would have never seen that
but dont you have output to detect that for you?
it didnt say that
gl on the journey then, doing good for first starting
luv bobox
lmk if you want extra context to why your first soluton didnt work
cause i dont think i explained it well
wdym my first solution
like in the first script you shown before we brought in the extra remote event
Just dont make a 4K high resolution Ray tracing Gta 6 copy right on the start of ur journey
cause there is a way to do it with just one, I just thought the second was simpler to understand
Chris
yo
no, probably faster, but dont worry about it too much
Goodluck. You think you are done
yea then having two is easier for me to visualize
good idea
wait till he learns about OOP and meta tables
Bro ray tracing
quick question tho
?
uh
tf is this bs
it wont let me put an outline cuz i have a UIcorner
yk
UIaspectRatio thing. it will change its size fitting to your resolution
thats why
so X and Y both get scaled at the same time
remove it and then you can give it different values to X and Y
you can add the ratio thing back later
its on the border stuff tho, hover over the icon and it should say a messagem or does it just say its cause of the ui corner?
show what it looks like in explorer
if i delete corner it shows the outline but it looks so ugly without corner
hm
oh instead of doing border mode, add a UIStroke object
to the button
Ui stroke is a built in object that gives a border to its parent, and will avoid the whole interference with the ui corner object
ex
i added it
ive never had problems with ui corners
dont see it tho?
yessir
epik, cause i have no idea what that means
does contextual mean it wont work if something is already messing with borders?
contextual = your text gets a stroke (literally) and border means the border of ur label
gets a stroke
what
oh weird, i was just wondering bc i had it on a frame and it didnt make a difference
u mean stroke/outline
yeah thats usually bc its contextual
just do border next time
it had me confused for weeks
yes thank u bro
is that everything for now?
well just one more question for now
when i load the game it says label until i click the button
0
then type 0 in it
in the explorer just set the text property of what you want the default to be
in that case 0 then
listen to Crusty 🔥
and then what if i want it to be what it was at before i left
do i need the save thing for that
that would need saves yeah
data storiiiing
chatgpt fumbles almost everywhere
true, just annoying in the hands of someone who doesnt know anything about scripting
yes
they start relying on errors
basically same as tuts
youll only know how to do whatever it is about, nothing else
Im off now
gn gang
gn
remotevent:FireServer(100000000000)
what the fuck
ez game
that is a problem for the future, bro started yesterday
@sand elk you still here?
** You are now Level 8! **
i got a question
yo
What problem do we have
Ill tp back to sleep then cya
lol
there is a separate property for text size
that is just the size of the ui object as a whole
oh im dumb
Ur learning, ur not dumb
w quote
Yessir
is it possible
to make the map untouchable
cuz i keep clicking on it instead of my ui
sad
uhh try
in the home tab unselect the select option
if not then idk there is no other way
should i do a ui upgrade thing or something on the map where u walk into it and its an upgrade store

like which one is simpler to learn
Map cuz then youll learn more
fax
like how do i make a ui pop up once i stand over a certain area
make a part, when player touches part, open gui
just do that, but like, in code
and you got that
Use Touched and TouchEnded
But I recommend proximity prompts
Anyways im off
Fr now
Cya
bai bai
im pretty sure that should work, like 75% sure
cause my original idea was doing on the server and sending a remote event, but your idea makes more sense
so go for that
a okay
so
what kind of gui would it be
if it has to pop up
oh wait im dumb
would it be a text box
then inside of the box there will be text buttons to actually buy stuff
@sand elk
wait textbox and textlabel look the exact same does it matter which one i use?
just a normal gui, with the shop inside of it
text box is a text label that the player can interact with and type in
like inserting a password as an example
ahh so id be using a text label for the actual frame of the ui
then inside the text label ill put text buttons
put everything inside a screen gui, then your script will enable and disable this gui
and use a frame, for the frame
oh so this ui should be in a completely separate screen gui
yes, generally I would have basically every menu that has a different function from the rest have its own gui
smart
yeah
like that
its so you can enable the guis you want on screen only when you want them to be on screen
instead of having to disable each individual frame or button inside of it
okay so its just to save myself a headache
a big one yes
ohh so the frame is the actual screen that they will see
and inside the frame i put buttons
yuh
1 line is better than 0
true
step one is to detect when the player has touched the part
using these events
okay wait so i need to make it so when you step on it it enables the frame
o yea that should prob be first step
the gui, yes
okay so
this is what i have so far
okay it didnt work
😭
didnt expect it to tbh
idrk what im doin
is the touched event not working?
well uh
this aint much of a touch event
maybe u see the vision
im completely wrong but u see what i was tryna do
ok so two, small ish, medium sized problems
first remove the if statement, and you want to connect the .Touched event to a function
second you are just trying to access the shop screen gui incorrectly
the correct order should look like
game.Players.LocalPlayer.PlayerGui.ShopScreenGui
then you can enable that
hm
so why do u have to go thru the players
and not just go directly to the gui
ohh
cuz its specifically accessing it for them
yes starter gui is the thing that is being replicated to the client when the player joins the game
which means it isnt representative if what the gui is for the player at any given time
and local player is a cool thing you can do in local scripts that will basically go directly to the player the script is running in
then you can go to the player gui from the player object LocalPlayer gives
yes
ok ok
but only local scripts can use it
because the server is like, the whole server
and stuff
i understand why this is how it is now
what i dont get is the touched events
ive only done like one and it was with a tutorial
you want to connect the event to a function, you did it before
and it will fire everytime something touched the part
part.Touched:Connect(function(hit)
print("Part has been touched")
end)
although something you will run into is that the touched event fires everytime anything touches the part
not only the player
so you will need an if statement inside of it to check if a player has touched it
kk
so why do i put hit there
an event is used for you to tell the computer that when something happens proceed with the function it connects to
the function within an event contains arguments that are useful for what theyre trying to do
hit is an argument given by the .Touched event that gives you what touched the part
it doesnt necessarily need to be called hit either its a variable name
would it be the same as putting touch or touched
yes, hit is just what i see it being called the most, but do what makes the most sense to you
check if the CanTouch property of the part in enabled
oh wait, check your variables
shop brick is most definitely not the workspace
whats the code now
where is this script located
Then yeah put it as a server script
I think .Touched is wonky with anchored parts locally
and you will just need a remote event to enable the gui
@crimson wedge
the remote event will be fired inside the function
for now just copy and paste the code to a server script
i just moved it to server script
does it work?
nope
also you dont need to reference your script, especially not in your context, but if you ever do in the future you can just use the "script" keyword
script is always equal to the script its in
and post the new script
ahh so i could just put the script instead of shopscript
yes, but delete it, cause you dont need it
send new screenshot
not much has changed
jsut deleted first line
was i supposed to do something more?
ahh
ok yeah, so the reason why it wasnt working on the local script is because the part was anchored
and theres a whole different reason why, but sick
now we need
and if statement
which is step 2
that checks if the thing that touched it is a player
so what about this if statement is wrong
im checking if its being touched
and if it is then it enables the screengui
the if statement goes inside of the function
also this is where the touch parameter you made comes in
you want to check if what touched the part is a player, for funsies see what happens when you print touch
it will give you a better idea of what it does
no yea i get what it does
its just the code thats tripping me up
i cant think of a way to check if a humanoid is touching it
only thing coming to mind is like,
if ShopBrick.Touched.Humanoid == true then
game.ShopScreenGui.enabled == true
but i dont think itll be another if statement
but you can get the parent of the thing thats touching it, and from there we can see if the humanoid exists
** You are now Level 12! **
basically your if statement will look like
if touch.Parent:FindFirstChild("Humanoid") then
.parent will be the player if its the player who touched it
and from the player we can get to the humanoid to see if it exists
this if statement is completely wrong
i think we need to take a step back here and talk about that
local function blah(arg)
print'hi'
end
this is a function
local function blah(arg)
print'hi'
end
part.Touched:Connect(blah)
this makes it so when part is touched the function blah runs
part.Touched:Connect(function(arg)
print'hi'
end
this is the same thing except we cant reference blah, it just automatically is set up for us
does that make sense
shopbrick.Touched isnt something you can check like a bool value
moreover the way you wrote it it will only run once at the start of the game and never again
thats why we connect the touched event, so it fires whenever someone touches the part
also, there is a difference between = and ==. we use = when declaring something, and == when checking it
if this == true then
versus part.Color = blue
ohh
okay so
me doing
ShopBrick.Touched:Connect(function(touch)
is creating the function
then i wanna call on it
for the if statement
is that right?
kinda? wording is interesting, you are just using the given parameter from the .Touched event in your if statement
also calling a function has a different meaning than what you are intending here I think, it means you are triggering a function to run, which is being doing automatically here
the function you defined is being called every time something touches the part
then .Touched gives us what touched it every time, so we can use that to do whatever code we want with it
hm
** You are now Level 9! **
to complete the if statement
oh
line 7 is fine
yeah just make sure everything is indented correctly, tab lines 5 & 6
and throw a print in there to see if it is working correctly
guess
yes, but how
we are on the server, and the server doesnt have access to the player's gui
Guis are ran exclusively on the local side of things, aka you cant edit a player's gui from the server
what so we need to make a local script?
yes
and put it in server script?
no
remote event
fire it to the local script
and the local script will enable the gui
feel like im missing something here
im making a local script
but not putting it in sever script service
no
then where am i putting it
server script service is for server scripts only, basically its only job
bc our script is handling ui, put it somewhere in starter gui, probably within the shop gui itself
alr so thats created
but before we move onto the local
this
the next step after confirming its a humanoid is opening the gui
fire the remote event, with the player as an arguement
these are generally where local scripts go, besides replicated first for loading screens
starter gui for gui stuff
starter character scripts (inside starter player) for anything relating to the in game character in the workspace, like animations, this is because scripts here are replicated to the player's character itself, and refreshing everytime the character dies
and starter player scripts (also inside starter player) for everything else, like logic ran on the client, or camera stuff
could u elaborate on firing the remote event
do you know how they work?
nope
A yt video could probably explain it better but ill try
The client and server are separate, so normally they cant really communicate with one another
but with the use of remote events, we can send information from one side to the other
its similar to how events work
so a test example, lets say when the player presses a button, I want a part to move on the workspace
The button pressing has to be done on the client because its a gui element, and the part moving has to be done on the server so everyone in the game can see it
so we set up a signal on the server that looks like
-- Server Script
remoteEvent.OnClientEvent:Connect(function(player)
--move part
end)
Then on the client we can trigger the event, aka sending the signal that the server is waiting for
-- local script
remoteEvent.FireServer()
The remote event itself is an object that usually goes in Replicated Storage, this is because everything in replicated storage is replicated to both the client and server, so both places can have access to it
Any questions before I go into the smaller stuff
hmmmm
im rereading this til i full understand
okay so
we create the remoteEvent on the server script
then fire it using the local script
think about it as a function more, we create the function on the server, and then calling it from the client
this does work in reverse order aswell, we can create functions on the client, and call then from the server
then on the local script in the shopscreengui i fire it
you are firing it from the server to the local script
because the function is enabling the gui
and you only want that to happen when the player is touching the shop part
so when the player touches shop part, fire the remote event
i feel like the termonology is messing me up
im making the event on the server script, on the local script im calling that event
yeah its kind backwards, calling a function is telling the function to execute the code inside of it
defining a function is the code we want to run when the function is called on
-- defining the function
local function myFunction()
end
-- calling the function
myFunction()
just think about it in the context of remote events, we are defining a function on one side, then calling it on the other
the function we defined is the code enabling the gui, and we are calling it on the server
yes good this is what i was meaning
now a question is
where do we define it
-- local script - defining the function
remoteEvent.OnServerEvent:Connect(function()
enableGui
end)
-- server script - calling the function
remoteEvent:FireClient(player)
by that i mean
both the server and the client needs to have access to it, so we define it in both scripts
i meant define it as in
where in my code
at 2
or at 6
since its a function
both would work, but 2 makes more sense, there is no need to redefine it everytime
This is the video I watched to learn remote events, or you can try the roblox documentation if you are still confused on parts https://www.youtube.com/watch?v=rxBldFKWaTc&list=PLQ1Qd31Hmi3WKkVHnadvhOOjz04AuMYAf&index=5
PATREON🎁
Get Access to My Scripts + More Perks by Becoming a Patreon Member!
https://www.patreon.com/BrawlDev
DISCORD 📜
Join my Discord Community if you want scripting help, participate in events/challenges, and make friends!
https://discord.gg/WC6kPu5W5P
ADVANCED ROBLOX SCRIPTING SERIES 🔴
https://www.youtube.com/playlist?list=PLQ1Qd...
this is a part of one his roblox studio tutorial playlists
im watchin
k
im gonna sleep cuz i wont retain anything if im barely awake
i really appreciate all of your guys help
gn, and np