#script not working
100 messages · Page 1 of 1 (latest)
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)
(button.MouseButton1Click:Connect(...dosomestuff
instead of is button.Mousebutton1click
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
yes it does
you get it? @potent surge
not really
And it doesn't change the text ?
lemme read
ok
it doesn't change text
Error ?
Any error ?
nope
oh
i fix all the errors i encounter
btw i still don't know how to do it
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)
u gotta just tell me where is the error
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
Server script or client script ?
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.
And player = game.Players.LocalPlayer
1 sec im helping someone
ok
** You are now Level 11! **
?
K
but i cant find his thread
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
His script works ?
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
alr
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
ok
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
np
yes
glad to hear that
There are people who don't even know how to enter Roblox Studio lol
that's why i do not understand most of the things
its okay
not a big deal
i can translate
if u want
no thx
np
i do understand common sense or whatever
ok, thx!