#Client and server

1 messages · Page 1 of 1 (latest)

main shore
#

I urgently need help

vapid ocean
#

Help help

main shore
main shore
#

its not updating live

#

and gpt is useless af

willow kestrel
main shore
#

so the quest thing i did dont update live

open oriole
main shore
open oriole
#

alr

#

but sounds like you need to use remote events, here is a little thing i wrote out for someone to learn off but you can prob use it to learn as well

client to server:

-- (local/client script)
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")

remote:FireServer() -- no value passed, just the player because this is a local (client) script, though you could put "player" if you wanted but you dont need to, this honestly might just create 2 player values if i recall correctly lol

results in the server script:

-- server script
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")
remote.OnServerEvent:Connect(function(player) -- need to put something here to assign the value
  print(player) -- will print the player
end)

---------------

server to client:

-- (server script)
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")

remote:FireClient() -- no value is being passed, it will by empty/nil unless we actually add in a value there

results in the local/client script:

-- local/client script
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")
remote.OnClientEvent:Connect(function(player) -- need to put something here to assign the value
  print(player) -- will NOT print the player because in the server script we lef it blank, this will print "nil"
-- in order to pass the player from a server to client/local script we have to connect the player to the player value AND pass it in the arguements() when firing
end)
main shore
#

Module


local QuestData = {
    [1] = {
        Name = "Train Your Strength",
        Stat = "Strength",
        Goal = 1000,
        Reward = {Yen = 500, Multiplier = 1},
        Description = "Train your Strength to get stronger.",
        Dialogue = {
            "Welcome, young fighter!",
            "Your first challenge is to train your Strength.",
            "Gain 1000 Strength and return to me."
        }
    },
    [2] = {
        Name = "Train Your Sword",
        Stat = "Sword",
        Goal = 500,
        Reward = {Yen = 1000, Multiplier = 2},
        Description = "Hone your sword skill!",
        Dialogue = {
            "Well done on your Strength!",
            "Now, focus on mastering your Sword skill.",
            "Gain 500 Sword and return to me."
        }
    },
    [3] = {
        Name = "Train Your Chakra",
        Stat = "Chakra",
        Goal = 300,
        Reward = {Yen = 1500, Multiplier = 2},
        Description = "Focus your mind and gain Chakra.",
        Dialogue = {
            "Impressive, you are growing stronger!",
            "Next, channel your energy to gain 300 Chakra."
        }
    }
}

return QuestData

#

the server and local is too long-

open oriole
#

you can send msg as file using discord

main shore
#

there

main shore
#

idk why the counter is not going up live.

dawn oceanBOT
#

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

open oriole
#

what is this counter

main shore
open oriole
#

i need more info crying

main shore
#

like yk

#

lets say

#

0/300 when i train , the counter doesnt go up

#

like it stays 0/300

#

doesnt update

open oriole
#

did u look to see what the errors said

#

in output

main shore
#

i did

open oriole
#

also you have a empty ref here and likely that has a red line under it

#

[sending pic]

main shore
#

i fixed it with gpt until there were no errors and it still dont work 😭

open oriole
#

gpt Takeitback

main shore
#

but there was this line tho-

#

12:11:31.438 Players.Iceyy_Hanss.PlayerScripts.Quest:116: attempt to compare nil < number - Client - Quest:116

main shore
open oriole
#

do yk any scripting

main shore
#

not at all lol js those basic making leaderstats and shit

open oriole
#

i dont wanna fix ai scripts comfy maybe i can help you make one

main shore
#

;-;

open oriole
#

ai is defo not made to write entire code, when it does its sh*t and doesn't work 90% of the time

#

it can be good for given direction and asking questions about coding but... thats really it

main shore
#

right.

#

thats why i was stuck for like 4 hours

open oriole
#

and from the looks of it, it doesn't seem to be simple leader stats or simple scripting (in my definition) ai could defo code a button for you but not this

#

with that script out of mind, what are you trying to do? i know you said leader stats, but that can look different for everyone

main shore
#

okay so im trying to make a quest system, Train chakra/strength/sword/durability and all those shit all the stats are stored in a Stats folder to get rewards/curencies like yen/sword or anything like that ykwim?

open oriole
#

yeah i kinda follow, do you have a premade folder or does a script make it for the player when they join?

main shore
#

it is already premade for everyone

#

so everyone who joins has it

main shore
#

and like to get the quest they must click on Madara(which is in workspace inside of madara has a Clickbox and then the clickdetector is inside

main shore
dawn oceanBOT
#

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

main shore
#

once Madara is clicked the dialogue frame appears and under the Main as u can see theres a Text that label should be the one saying the dialogues ykwim and the the NPCName u see the one saying Madara [1/6] should display the npc name and how many slides/whichslide the player is on

#

ykwim

#

or are u stuck-

open oriole
#

so first off are we handling the dialogue coding first? im trying to break this down lol, or do you have that code finished

main shore
#

and btw the quest progression should be here-

open oriole
#

alrighty fine with me :D and is this a one player quest? or a group thing

#

probably sounds silly but gotta make sure 😭

main shore
#

group quest..?

#

never heard of it

open oriole
#

as in uhhh is this quest for just one player

main shore
#

i understand

#

i meant

#

ive never seen a game done group quest

open oriole
#

sometimes theres games that will have a quest for your team, that kind of deal yk

main shore
#

ah

#

understood

open oriole
#

ok anyway 😭 if this is where the speaking text will be, id suggest naming it something like 'dialogue_text' or something

main shore
#

yes and done

open oriole
#

do you want them to click on the npc's body/model with their mouse/finger or maybe a proximity prompt, or maybe even a on-screen button?

main shore
#

so once they click the clickbox it should work-

open oriole
#

as long as there is nothing in the way then click detector should be fine, personally i use proximities BUT we can do the detector if you want lol

main shore
#

yee ty

#

pretty avi btw

open oriole
#

lol tyty

#

sorry these questions are prob annoying but can i see where the click det is

main shore
#

nono idc

#

ask as many as uw

#

there

open oriole
#

whats the billboard gui 🤔

main shore
#

uh

#

madara's name HAHAHA

open socket
open oriole
#

ooh lol

#

i did this, but idk if yours is animated

main shore
#

Uh yesyes that is correct but i cover the entire avatar

open oriole
#

okurs im assuming it wont make much difference mine covers them as well

open socket
#

whtas even the problem, just asking 💔

open oriole
#

local scripts dont work in the workspace, so we can either slap a server script that will do a remote event or a local script in the player scripts, but i think remote event is better

open oriole
open socket
open socket
#

yeah im guessing he doesnt understand it

#

alright

#

ggs

main shore
main shore
open oriole
main shore
dawn oceanBOT
#

studio** You are now Level 4! **studio

open oriole
#

sorry for the waits

main shore
#

npnp

open oriole
#

since we are doing a remote, you can go ahead and add a remote even object under rep storage, this is usually where most people put theirs,, you can even sort them using folders but you'd have to update the code because you'd be changing the path to your remote event object

#

i named mine NPC_Activated :>

main shore
open oriole
#

yes to your previous msg lol

anyway-
then a server script can go under your click det, you can use a mouse click function for detecting mouse clicks

local remoteEvent = game:GetService("ReplicatedStorage"):WaitForChild("NPC_Activated") -- used to fire to the client, like a signal, think of this as a satalite 
-- you can also refrence your click det' but since it a parent, i wouldn't bother
script.Parent.MouseClick:Connect(function(activator) -- activator is the player
-- note player vs player's model are different :D

end)
#

visual ^

#

screenshot code if you prefer to follow that one instead:

local re = game:GetService("ReplicatedStorage"):WaitForChild("NPC_Activated") -- used to fire to the client, like a signal, think of this as a satalite

script.Parent.MouseClick:Connect(function(activator) -- activator is the player
    warn(activator, "clicked!") -- yay wow so cool

    
    local exampleInfo = "You just passed over info!"
    -- we need a local script, so lets make sure our local script knows
    -- the it has been activated and should be doing it's cool code stuff now
    
    re:FireClient(exampleInfo) -- anything in side the () is the info we are passing over
    -- since we are about to work in a local script, we dont really need activator to be passed over because
    -- we can get the player using a local script with ease unlike server scripts

    -- if this was client(local) to server then we would want to pass over the player(activator) because getting
    -- the local player in a server script can be a huge pain sometimes because while a client(local) script "sees"
    -- just the target player, the server script "sees" all players    
end)
#

you can even test this, if you used the screenshot code, it should print orange text that says "[your name] clicked!"

main shore
#

eh.

#

weird-

#

lemme check smth

main shore
#

never

#

mind

#

okay whats next

open oriole
#

you got it to work?

#

lol

main shore
#

ye

#

js tweaking a little

#

havent had my sleep lol

open oriole
#

oh dang

#

well lmk if you need to go to bed, but i suggest putting your local script in the gui, i badly replicated your gui lol

#
local re = game:GetService("ReplicatedStorage"):WaitForChild("NPC_Activated")

re.OnClientEvent:Connect(function(info) -- if we passed info, we'd want to refrence it inside the ()
    print(info) -- this should print "You just passed over info!", just for example, we don't need this for the script!
    
    -- make sure the above prints!!!
    
end)
#

waitt scratch that

main shore
#

hmm

#

wait

#

@open oriole

#

why dont i join ur studio and add the frames there- so yk we woundt clash later or smth ykwim

#

if thats okay w u lol

open oriole
#

so i forgot that there NEEDS to be some sort of value passed over even if we dont use it, so in the

re:FireClient(activator, exampleInfo)

since it's passing to a local script the first value will be exampleInfo

updated:

-- server script under the click det'
local re = game:GetService("ReplicatedStorage"):WaitForChild("NPC_Activated") -- used to fire to the client, like a signal, think of this as a satalite

script.Parent.MouseClick:Connect(function(activator) -- activator is the player
    warn(activator, "clicked!") -- yay wow so cool

    -- we need a local script, so lets make sure our local script knows
    -- the it has been activated and should be doing it's cool code stuff now
    
    local exampleInfo = "you have passed over info!"
    
    re:FireClient(activator, exampleInfo) -- anything in side the () is the info we are passing over
    -- since we are about to work in a local script, we dont really need activator to be passed over because
    -- we can get the player using a local script with ease unlike server scripts

    -- if this was client(local) to server then we would want to pass over the player(activator) because getting
    -- the local player in a server script can be a huge pain sometimes because while a client(local) script "sees"
    -- just the target player, the server script "sees" all players    
end)

and

-- local script inside the gui
local re = game:GetService("ReplicatedStorage"):WaitForChild("NPC_Activated")

re.OnClientEvent:Connect(function(info) -- if we passed info, we'd want to refrence it inside the ()
    
    -- this is a local script so we dont need to add the player(activator)
    -- if we was to add activator to our () above it would be nil
    
    warn(info) -- this sound print "you have passed over info!"
    
end)
open oriole
#

im trying to help you understand so im sorry if im confusing you 🙏 i just dont wanna be the type to throw free code at you and you learn nothing crying

main shore
#

nono i understand

#

its okay

#

i rlly wish i got someone like u whos willingly teaching me

open oriole
#

should be smthn like dis btw lol

main shore
#

but like i told u i havent got any sleep and i cant sleep cuz my brain wouldnt let me if i havent finished yet 😭 and maybe after finishing u could teach me more

main shore
open oriole
#
-- removed uneeded code from before, this is the client(local) script that is inside your gui
local re = game:GetService("ReplicatedStorage"):WaitForChild("NPC_Activated")

local db = true
-- this is like a cooldown, debounce works with true/false (bool) values
--rather than a number-based cooldown (countdown to end)

local questGui = script.Parent

re.OnClientEvent:Connect(function()
    
    if db == true then-- if it's true, then the code inside will run!
        db = false -- setting it to false means if we trigger the 'OnClientEvent' function again
        -- the code inside here wont trigger, only when db is true
        
        -- we will set the db to true again when we are done runnning our code
        
        
        --lets simply enable the ScreenGui
        
        questGui.Enabled = true
        
    end
        
end)
#

i assumed you're wanting the gui to appear via screenGui.enabled/disabled, but let me know if its different

main shore
#

uh. nooo

open oriole
#

is it frame visibility?

main shore
#

Frame visiblity true/false

#

yeee

open oriole
#

oki you can just do

questGui:WaitForChild("TheFrameYouWant").Visble = true
#

is the the 'main' frame or 'dialogue' frame? just so that mine is accurate

main shore
#

Dialogue

#

questGui:WaitForChild("Dialogue").Visble = true

open oriole
#

yas

#

you can test it :>

#

make sure its not visible in studio

open oriole
main shore
#

uh

#

i changed it already xd

open oriole
#

worked so far? so that we dont have to backtrack to errors lol

dawn oceanBOT
#

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

open oriole
#

yipee so now the gui appers

#

did you want a type-writer effect for the npc or will the text just be there

main shore
#

e-typer

#

heh

open oriole
#

e typer? 🤔

main shore
#

yesyes hehe

open oriole
main shore
#

yessirr

open oriole
#

oki good good

#

e typer must be another name

#

i always called it type writer xd

main shore
#

oo old i like

#

xd

open oriole
#

now i introduce callable functions >:))

don't use this yet, just read

local function typeWriterEffect(text, textLabel) -- this is a bit complex for starters so don't worry if you don't grasp it right now
-- we can set what the text and textLabel mean when we call the function
    
    textLabel.Text = " " -- setting the text empty first, or we'll only be adding text
    
    -- if you want a sound, like a bleep sound that plays every time a letter appears let me know :D
    
    local charIndex = 1 -- how many letters will appear at a time
    local typingSpeed = 0.05 -- typing speed :>

    
    local function updateText() 
        -- Get the current text
        local currentText = textLabel.Text

        -- if reached the end of the text..
        if charIndex > #text then
            -- stop updating the text
            return
        end

        -- update the text by adding the next letter
        textLabel.Text = currentText .. string.sub(text, charIndex, charIndex)

        -- addd the character index (simple math)
        charIndex = charIndex + 1

        -- wait for the [typing speed] amount of time before the next letter
        task.wait(typingSpeed)
    end

    -- repeat the function until the text is over :>
    while charIndex <= #text do
        updateText()
    end
end

to call it id do

local myTextLabel = blah.blah.blah

typeWriterEffect("this is my text", myTextLabel)

when calling it, and adding info in the () you're setting references for the (text, textLabel)
basically its like doing:

local text = "this is my text"
local textLabel = blah.blah.blah

lmk if that makes sense lol

#

if you ever heard of modules, this is very very similar, honestly making this a module would mean you can call it anywhere in any script :>

main shore
#

damn.

#

ykw play that sound :))

open oriole
#

find a sound you want, but keep in mind it plays with every letter so you'd want something short lol

#

lemme find one i used, if you want to hear it (found it on rblx store)

main shore
#

lemme hear

open oriole
#

for female npcs i would make the pitch higher (via pitch)

#

wait thats 100% thw wrong one

main shore
#

0 sec

#

xd

open oriole
#

i make a talking npc for a game's previous map but they made a new map and deleted the place so i have no way to see the sound now lol

main shore
#

hm actually thats nice

open oriole
#

capturing children /j

main shore
#

.

#

what

open oriole
#

tiny rigs run around and you capture them with nets 💀 i would joke and say out of context this sounds horrible

main shore
#

nah u woked for a P

open oriole
#

noo 😭

main shore
#

let me

#

rephrase

#

U HELPED MAKE

#

A P GAME

open oriole
#

what u on about 😭😭

#

haha

main shore
#

dont even get started on what the npc do/say

#

😭

open oriole
#

it was a guy named joe and he sold boats

#

😭

main shore
#

its always the joe

#

i swear

open oriole
#

lmfaooo

#

it wasnt a creepy game i swear lol

#

i was like "guys this lowk seems like a kidnapping game"

main shore
open oriole
#

the little rigs are devs, or popular youtubers

main shore
#

HAHAAH

open oriole
#

lemme show u one of their old images rq

open oriole
#

hey commissioned this but i think they got scammed ngl cuz this might be ai

#

and the other guy isnt even small </3

main shore
#

that

#

is

#

def

#

ai

open oriole
#

i cant show a lot but i made nets but i dont do good cartoony styles so it reasonably got rejected lol this one was space themed

main shore
#

nah

#

ur a modeler too?

open oriole
#

im more of a realistic-ish like old graphic games

main shore
#

damn.

open oriole
#

i assist that net game but i used to script for them but they hired a ton others and i tried to work with them but uhhh i just cant lol

main shore
#

id ask u to join me lol but idt u wld

open oriole
#

the only thing i cant do at all is visual effects

main shore
#

i havent even hired anyone only one is a modeler but that was it

open oriole
#

plus lowk it seems like everything i made for them just ends up getting scrapped but that happens in development so im not super mad but ykk a little sad

main shore
#

why

#

wait can we talk abt this more in dms and abt the dev here cuz i wanna talk smth private too xd

open oriole
#

shore

open oriole
bright glacier
#

really? never knew that lol

open oriole
#

yeah not worth the extra 5 characters lol

#

player will print as the name regardless, like if you were to print a block it will print the name of the block

open oriole
bright glacier
#

lol

open oriole
#

im not suppose to be in my house rn cuz we have a gas leak but its cold outside smh

#

my eyes are burning YEP