for @RobloxTitan4223’s solution, the string is just a placeholder for the object’s directory, change it to the object’s place like workspace.Part
etc
i dont know what you mean
what i gotta do on there
do
local part = [directory]
for example, if I have a part in workspace
then I would do local part = workspace.Part
or if i have a part in ReplicatedStorage
I would do local part = game:GetService("ReplicatedStorage").Part
when referencing objects, you have to give the location of where they are
like I did earlier with local cd = script.Parent
alright its works of somekind cause it just makes it red without even clicking it but let me explain the thing i wanna do :
Hello, you can do this. Put a click detector in the part you want to change. Then put a script in the click detector. You can then type this(“I’ll explain the code later”) Name the receiver “receiver”
script.Parent.MouseButton1Click:Connect(function())
if workspace.receiver.Material == Enum.Material.Neon then
workspace.reviever.Material = Enum.Material.SmoothPlastic
elseif workspace.receiver.Material == Enum.Material.SmoothPlastic then
workspace.reviever.Material = Enum.Material.Neon
end
end
When the script’s parent(In this case the ClickDetector) is clicked, it’ll run something. If the reciever’s Material is Neon, then turn it to smooth plastic. Else if it’s smooth plastic, turn it into neon.
Yay I posted my third reply
something for this would be
local reciever = [directory] -- the reciever
local button = [directory] -- the button
local cd = button:FindFirstChildOfClass("ClickDetector") or Instance.new("ClickDetector") -- find a click detector, if it can't find one, it will make one
if not cd.Parent then cd.Parent = button end -- if the script created a clickdetector then it will set it's parent to the button
local recieverIsEnabled = false -- default value for the reciever
local neon = Enum.Material.Neon -- the neon material
local smoothPlastic = Enum.Material.SmoothPlastic -- the smoothplastic material
cd.MouseClick:Connect(function(player)
if not recieverIsEnabled then -- if the reciever is disabled
recieverIsEnabled = true -- set the value of "recieverIsEnabled to true"
reciever.Material = neon -- set the reciever's material to neon
else
recieverIsEnabled = false
reciever.Material = smoothPlastic
end
end)
Edit: fixed a few typos
it would be script or local script and where do i put it? and can you make it that is multiple parts?
It would be a script, you can put it in ServerScriptService
, and do you mean, allow the script to reference multiple parts or put the script in multiple parts?
btw sorry for answering late i was at gym
reference multiple parts and if so ill put you on the solution
You can change directory
to their individual locations
example:
local part0 = workspace.Part
local part1 = workspace.Part.Object
and what would be the script for multiple parts if thats easier.
it’s basically copy+pasting the script into different parts, i don’t recommend it tho because if you update one script, you would have to update all of them
would it work if its inside a model?
yea, just make sure that you give the correct locations for them
alright like this?
no, those are strings, not objects. wait, send a picture of your workspace
or this
Workspace like this lol