Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a button change a block?

Hello!

I'm trying to make a button in Roblox change a different block when pressed. So like say there was a button called "button" (creative I know), say there was a part named "receiver." I'd want it to be so that when button was clicked, receiver would change block texture, for example, from smooth plastic to neon.

I tried doing this with the code I used to make the block change color when pressed, but got no luck with that. I also tried mixing the color code, with a code that made the block change textures when you stepped on it. Once again, no luck.

Anyone know how to do this? Also excuse the username haha

Thanks in advance!

1 answer

✓ Accepted answer

What you need to do is make a remote event (you seem new to this heres a link: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events )

So put a remote event in replicated storage then name it "ChangePart" this can actually be what ever you want but for the example we'll use this

make a Button then a local script in the button then type this

local button = script.Parent
button.MouseButton1Click:Connect(function()
game.ReplicatedStorage.ChangePart:FireServer(Enum.Material.Neon) -- neon can be changed but must Enum.Material
end)

now go to server script service and make a regular script and put this

game.ReplicatedStorage.ChangePart.OnServerEvent:Connect(function(plr, Mat)-- first is always a player
local brick = --DefineBrick
brick.Material = mat
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.