Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I fix "Syntax Error: Expected Identifier when parsing function name, got '('"?

sorry if this is some stupid question but I am new to scripting and I really don't know what to do. here is my script:

boolvalue = game.StarterGui.lever
clickdetect = script.Parent.ClickDetector
main = script.Parent
main2 = script.Parent.Parent.Main2

function(onClick)
	boolvalue.Value = true
	main.Transparency = 1
	main2.Transparency = 0
end)
clickdetect.MouseClick:Connect(onClick)

the error is on the (onClick)

3 comments

0

What is inside the parentheses are the arguments, not the name of the function, to properly make a function, do "function myFunction(arguments)"

0

What are you doing in StarterGui though? Are you aware that changes in StarterGui won't affect the Players? I believe the changes you want tot make is in PlayerGui

0

I was trying to enable a bool value when a button is pressed and this is the same way I made all of my other scripts with a click detector but for some reason it didnt work now

1 answer

✓ Accepted answer

you have wrong syntax for the function and you shouldnt use globals

local boolvalue = game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("lever")
local clickdetect = script.Parent.ClickDetector
local main = script.Parent
local main2 = script.Parent.Parent.Main2

function onClick()
    boolvalue.Value = true
    main.Transparency = 1
    main2.Transparency = 0
end

clickdetect.MouseClick:Connect(onClick)

Furthermore

you are modifying the StarterGui, everything thats inside the startergui gets cloned into the PlayerGui of a player so if you modify something in StarterGui it will only show after the players dies so if you want the modify it instantly you have to modify the PlayerGui

the PlayerGui is part of the player. like this Player.PlayerGui

see PlayerGui vs StarterGui

3 comments

0

I moved the values but the syntax error still shows on the brackets

0

I edited the code, it contained an extra parenthis that I didnt see at first

0

I am so dumb, I haven't scripted in a few weeks so my mind was boggled.

This discussion is preserved as it was. New answers, comments, and votes are closed.