My tapping button isnt going up 1 in the counter when i click it

i have read throught this script and all i can find that might be wrong is the word script. Btw my script is meant to make a counter go up 1 every time a click a button i made in my game it always the word script in red and in the output it says


Also this is my actual script

1 Like

why is there local at the end of the line

1 Like

i could be wrong but i think it needs to be script.Parent not script.parent

2 Likes

well, as i am new to scripting i tried putting other words at the end to see if they worked but they didnt. I obviously checked if it worked without any words at the end too

activated works better than mousebutton1click

1 Like

let me try it ok i will tell you if it works

your error seems to be in line 8, the local is obviously breaking the script because it hasnt been attached to some sort of variable

1 Like

i have removed the local and it still doesnt work i also have changed the p to P for script.Parent

also have tried activated and mousebutton1click

what is your output? any errors?

i will post the output again as there is a new red line

The connected function looks inconsistent. One of them is script.Parent.Parent.ScreenGui2.Frame2.counter.Text
The other is script.Parent.Parent.Frame.screenGui2.Frame2.counter.Text


this is the new output

What does your current script look like? Also screenshot the explorer so we know where “counter” is


this is my script and this is my explorer
image

try this maybe ?

buttonstart.Activated(connect(onButtonActivated))

local buttonstart = script.Parent.Frame.ImageButton
local counter = script.Parent.Parent.ScreenGui2.Frame2.counter
local function onButtonActivated()
    counter.Text = tonumber(counter.Text) + 1
end
buttonstart.Activated:Connect(onButtonActivated)

You put :Activated instead of .Activated, and I just made it neater.

thankyou but these havent worked either

change this line to

local counter = script.Parent.Parent:WaitForChild("ScreenGui2")

This is a weird thing of how roblox loads stuff.

thankyou so much for helping me but this still isnt working