How do i make a part that when you click prints working created by

how do i make a part that when you click prints working created by

So far i have tried adding a script and click detector inside the part but its not really working. I have gotten some errors that iv never seen in my life before.

Does anyone have a solution to the issue?

Game summary:
My game is about clicking a part that is generated using instance to new and math.random on a 3d plane.

Players try to click the brick before others to gain points to spend at the shop.

Note: all my scripts are local.

Here are some of the errors i’m getting:
“The Parent property of workspace is locked; current parent: button clickers, new parent part”


(Just nothing happening)

The scripts are:

Local clickdetector = game.Workspace.Part[“instance script”] 
Game.workspace[“Click detector guy”]:FireServer () 

The script i put in the

However for some reason it just does nothing instead of doing the action.

Make sure only ServerScripts use also, at the event, the variable is written with a capital “C” unlike in the variable. Also, try writing game in lowercase. Use your remoteevents in replicated storage. Also, you have to connect the event to start the function.

It should look somewhat like this:

local Clickdetector = game.Workspace.Part["instance script"] --path

Clickdetector.MouseClick:Connect(function(plr) --connect the function and pass the player paramter
game.ReplicatedStorage.Events["Click detector guy"]:FireServer() --Make sure the event is in a folder called "Events" in replicated storage
1 Like
  1. So if i put that script in server storage and a click detector in the instanced part, it will work?

No because you aren’t connecting the event, use :Connect() to connect an event.

Also ClickDetector must point to a ClickDetector

No. Localscripts don’t run in ServerStorage, and Serverscripts can’t use FireServer().

This is invalid code in many ways.

  • You have all the variables mixed up names. You define clickdetector, and the try connecting ClickDetector
  • Game is not a global variable (game is)
  • Print is not a global variable (print is)
  • End is not a keyword (end is)
  • ClickDetector.MouseClick is an event which you call :Connect on
  • ClickDetectors don’t have a :FireServer() method

Thank you for putting the code in a code block, you also have to indent the code properly to make it readable.

where do i put it then? its not working in workspace

-- server script in ServerScriptService

local brick ="Part")
brick.Parent = workspace

local clickDetector ="ClickDetector")
clickDetector.Parent = brick

    print(player.Name.. " clicked the brick")

-- this code creates a Part and ClickDetector on the server (so it replicates to everyone) 
-- and prints the players name when any player clicks on the brick
1 Like

as always your scripts work. thanks bro

1 Like

of course!

Also watch this entire tutorial series by AlvinBlox to learn how to script (that’s how I learned how to script)

local clickDetector = script.Parent

	local brick ="Part")
	brick.Parent = workspace
	print(player.Name.." created a brick!")
1 Like