#script not working

100 messages · Page 1 of 1 (latest)

ocean lynx
#

Is you print something when button 1 is clicked does it print ?

karmic bramble
#

hi

#

what is the script for

#

what game r u making

#

looks like the issue with ur code is that you need to connect the MouseButton1Click event of the button first to make it trigger the click event also you should wrap your event handling code inside a function and then call that function when the MouseButton1Click event triggers here is how you can modify your code

local player = script.Parent.Parent.Parent.Parent.Parent
local button = script.Parent
local textbox = script.Parent.Parent:WaitForChild("textbox")
local leave = script.Parent.Parent:WaitForChild("leave")

-- define function to handle button click event
local function onButtonClick()
button.Text = "continue"
textbox.Text = "I'm the tutorial NPC and you are definitely a beginner because you talked to me."
end

-- connect button click event to onButtonClick function
button.MouseButton1Click:Connect(onButtonClick)

-- define function to handle leave button click event
local function onLeaveButtonClick()
textbox.Text = "What?"
button.Text = "Your name is the Tutorial, so uh..."
end

-- connect leave button click event to onLeaveButtonClick function
leave.MouseButton1Click:Connect(onLeaveButtonClick)

ocean lynx
#

(button.MouseButton1Click:Connect(...dosomestuff
instead of is button.Mousebutton1click

karmic bramble
#

in this code we define two functions onButtonClick and onLeaveButtonClick to handle the button click and the leave button click events respectively Then we connect the functions to the MouseButton1Click events of the two buttons using the Connect() method
i hope that helps mr 4thAdham

karmic bramble
#

you get it? @potent surge

potent surge
#

not really

ocean lynx
#

And it doesn't change the text ?

potent surge
#

lemme read

karmic bramble
#

ok

potent surge
ocean lynx
#

Error ?

potent surge
#

i don't get it

#

im braindead

#

.-.

ocean lynx
#

Any error ?

potent surge
#

nope

karmic bramble
potent surge
#

i fix all the errors i encounter

karmic bramble
#

alr

#

😂

#

just

#

use thus code

#

this

potent surge
#

btw i still don't know how to do it

potent surge
#

i write my codes myself

karmic bramble
#

local player = script.Parent.Parent.Parent.Parent.Parent
local button = script.Parent
local textbox = script.Parent.Parent:WaitForChild("textbox")
local leave = script.Parent.Parent:WaitForChild("leave")

-- define function to handle button click event
local function onButtonClick()
button.Text = "continue"
textbox.Text = "I'm the tutorial NPC and you are definitely a beginner because you talked to me."
end

-- connect button click event to onButtonClick function
button.MouseButton1Click:Connect(onButtonClick)

-- define function to handle leave button click event
local function onLeaveButtonClick()
textbox.Text = "What?"
button.Text = "Your name is the Tutorial, so uh..."
end

-- connect leave button click event to onLeaveButtonClick function
leave.MouseButton1Click:Connect(onLeaveButtonClick)

potent surge
#

u gotta just tell me where is the error

karmic bramble
#

then

#

do what u want

#

i told u

#

looks like the issue with ur code is that you need to connect the MouseButton1Click event of the button first to make it trigger the click event also you should wrap your event handling code inside a function and then call that function when the MouseButton1Click event triggers

ocean lynx
#

Server script or client script ?

karmic bramble
#

In this code we define two functions onButtonClick and onLeaveButtonClick to handle the button click and the leave button click events respectively Then we connect the functions to the MouseButton1Click events of the two buttons using the Connect() method.

ocean lynx
#

And player = game.Players.LocalPlayer

karmic bramble
#

1 sec im helping someone

potent surge
#

ok

flint sapphireBOT
#

studio** You are now Level 11! **studio

ocean lynx
karmic bramble
#

im helping someone

#

to make a gun

ocean lynx
#

K

karmic bramble
#

but i cant find his thread

potent surge
#

im looking for what is different between ur script and mine

#

so i know what i did wrong

#

btw thx for help

#

i do really appreciate it

ocean lynx
#

His script works ?

karmic bramble
# potent surge so i know what i did wrong

looks like the issue with ur code is that you need to connect the MouseButton1Click event of the button first to make it trigger the click event also you should wrap your event handling code inside a function and then call that function when the MouseButton1Click event triggers

#

i said million times lol

potent surge
#

ok

#

i don't understand so im tryna figure it out my self

karmic bramble
#

alr

potent surge
#

i don't completely know what did i do wrong but i can safely say i do understand and thx for help!!

#

i do now

#

but not really

#

idk how to explain

karmic bramble
#

np!

#

just use mine

#

its so good

#

if u didnt like

#

delete it

potent surge
#

ok

karmic bramble
#

did it work

#

@potent surge?

#

how is it going

potent surge
#

yes

#

it all worked

#

thx

#

the way i did use the functions wasn't the correct way

#

i should have used local functions like what u did

#

and then trigger it once the button is clicked

#

that's what i did understand

karmic bramble
#

np

karmic bramble
#

glad to hear that

potent surge
#

u r one of the few people

#

that did make an idiot understand smth

#

XD

karmic bramble
#

LOL NO

#

ur not idiot

potent surge
#

wym

#

i mean im not actally an idiot

#

it's just that my english is trash

karmic bramble
#

There are people who don't even know how to enter Roblox Studio lol

potent surge
#

that's why i do not understand most of the things

karmic bramble
#

not a big deal

#

i can translate

#

if u want

potent surge
#

no thx

karmic bramble
#

np

potent surge
#

i do understand common sense or whatever

karmic bramble
#

alr

#

have a good day adham!🌿

potent surge
#

ok, thx!