It actually works! But it needs to be in a local script, a local script only happens for you, unless you use a remote event or a remote function
Insert a Local Script In the StarterPlayerScripts in the StarterPlayer tab on your Explorer
Also do like this
game.Workspace.Part2.BrickColor = BrickColor.new("Navy blue")
That will change the brickcolor
then insert your script :)
local ClickDetector = game.Workspace.MyPart.ClickDetector
ClickDetector.MouseClick:Connect(function()
game.Workspace.Part2.BrickColor = BrickColor.new("Navy blue")
end)
I know this has got nothing with your question to do but, there is something called a Remote Function
Remote functions basically makes a Local Script Visible to everyone.
"Whats the point of using a Remote Event when you can just do it in a Normal Script!"
Well, A script does not always work in a Normal Script, for example if we want to make your script visible to everyone, then it would not work in a normal script. So thats why we use Remote Events and why they are usefull
local ClickDetector = game.Workspace.MyPart.ClickDetector
local RS = game:GetService("ReplicatedStorage")
local RemoteFunction = RS:WaitForChild("RemoteFunction")
local MyPart = ClickDetector.Parent
ClickDetector.MouseClick:Connect(function()
RemoteFunction:InvokeServer(MyPart)
end)
Create a Normal script in the serverscript
local ClickDetector = game.Workspace.MyPart.ClickDetector
local RS = game:GetService("ReplicatedStorage")
local RemoteFunction = RS:WaitForChild("RemoteFunction")
local MyPart = ClickDetector.Parent
RemoteFunction.OnServerInvoke = function(player, MyPart)
MyPart.BrickColor = BrickColor.new("Baby blue")
end
If you are a beginner i don't recommend you to just jump into Remote-Functions. I was just teaching you ahead
1 comment
Can you use codeblocks?