how do i make a part that when you click prints working created by instance.new()?
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”
Make sure only ServerScripts use Instance.new() 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
print("ran")
end)
-- server script in ServerScriptService
local brick = Instance.new("Part")
brick.Parent = workspace
local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = brick
clickDetector.MouseClick:Connect(function(player)
print(player.Name.. " clicked the brick")
end)
-- 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
local clickDetector = script.Parent
clickDetector.Mouse1Click:Connect(function(player)
local brick = Instance.new("Part")
brick.Parent = workspace
print(player.Name.." created a brick!")
end)