Why isn't the script working?

Okay so, Im a beginner at scripting and I made a part with a SurfaceGui and 2 buttons (and a text label). I put the local script inside the part, a click detector and the Surface. I made this script…

local SheIs = game.Workspace.Prova1.SurfaceGui.SheIs
local SheAre = game.Workspace.Prova1.SurfaceGui.SheAre
local ClickDetector = game.Workspace.Prova1.ClickDetector

ClickDetector.MouseClick:Connect(function()
	if SheIs then
		script.Parent.Transparency = 0.5
		script.Parent.CanCollide = false
	elseif SheAre then
		SheAre.BackgroundColor3 = Color3.fromRBG (239, 78, 78)
	end
end)

But its not working, I checked some posts about this but I have no idea of how to make the script work and idk what is wrong, there aren’t any errors at all.

2 Likes

U can just do this way

local SheIs = game.Workspace.Prova1.SurfaceGui.SheIs
local SheAre = game.Workspace.Prova1.SurfaceGui.SheAre

SheIs.MouseButton1Click:Connect(function()
	script.Parent.Transparency = 0.5
	script.Parent.CanCollide = false
end)
SheAre.MouseButton1Click:Connect(function()
	SheAre.BackgroundColor3 = Color3.fromRBG (239, 78, 78)
end)

i didnt test but might be working

It still doesn’t work :frowning: but thanks

are the SheIs and the SheAre textbutton or imagebutton

SheIs and SheAre are Text buttons.

if they are text buttons you dont need the click detector

you just need to get the direct input of these buttons

You can’t have a localscript in a server side part. It won’t work.
Try putting the localscript in StarterGui.

Could you send us an image of your workspace?

1 Like

try changing from a local script to a script

Basically that’s my workspace without changing anything
imagem

You could change the localscript to a script

and you don’t need the clickdetector

Okay but if I changed it to a script wouldn’t what one person clicked happen to everyone or something?

If you want it to happen only to him put the local script on the player scripts folder or in the starter gui

1 Like

Try doing a server script instead.

She wants only the player that clicked to happen that

Still, server script. She would need a remote even as well.

I was just thinking of that XD

Why wold I need a remote event

If you try to do it only local script, it wouldn’t work. Remote event is an advantage of cross server communication.

But she wants all in the local