Simple clickdetector color change script issue

I’m trying to make a part color change locally. I’m doing this using a remote event but I can’t find anything on the devhub, youtube, or devforum to fix this simple script. In the output it responds to my issue by saying "Part1 is not a valid member of Workspace “Workspace”. I’ve also tried to use local scripts by themselves as well and to use local functions.

local script:

game.Workspace.Part1.ClickDetector.MouseClick:Connect(function()
	game.Workspace.Event.OnServerEvent:FireServer()
end)

script

game.Workspace.Event.OnServerEvent:Connect(function()
	script.Parent.Parent.Part1.Color = Color3.new(0.380346, 1, 0.348455)
end)

Ensure that Part1 is anchored or has can collide on.
Also, you should be using a RemoteEvent, so ensure you aren’t using a bindable event or smth.

You can also try adding game:Workspace:WaitForChild(“Part1”) instead of game.Workspace.Part1

Everything is correct and I set it to game:Workspace:WaitForChild(“Part1”) yet it still doesn’t function properly and there is nothing in the output.

What script is erroring? Is it hte local script or the server script?

The local script is erroring, it definitely has something to do with the local script.

You don’t do

Event.OnServerEvent:FireServer()

you do

Event:FireServer()

Hope it helps
Edit: You use OnServerEvent when connecting the remote from client to server, so the server script you got is alright.

2 Likes

From the official documentation:
“ClickDetector events fire on both the client and the server. Since a LocalScript will only run if it descends from a Player or player Character, it’s usually not useful to put a LocalScript inside a ClickDetector, since the script won’t run or the object won’t be clickable. If you need a LocalScript to detect ClickDetector events, StarterPlayerScripts may be a better place instead.”

I’m trying to think of a solution but the documentation is very vague

Nah he just had referenced the remote event incorrectly that’s why (already explained in the other reply I sent)

Edit: Wait I just read the entire thing about Part1 is not a valid member of workspace, well, even if that thing worked the point I made still stands so now you only have 1 issue!
Regards this one its probably what this guy above said

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.