Right so,
I’ve been working on a custom material feature for my build mode system. Basically, it changes all the textures found in an object, by clicking a button. You need to input the texture ID, and then you can change the texture of any object.
My problem is, the textures doesn’t change, even tho everything in the client side works perfect. But on the actual server, nothing happens…
Here’s my code:
TextBox:
script.Parent.FocusLost:Connect(function(enter)
if enter then
if script.Parent.Text then
script.Parent.Parent.MaterialPreview.Image = "rbxassetid://" .. script.Parent.Text
local asset = game:GetService("MarketplaceService"):GetProductInfo(tonumber(script.Parent.Text), Enum.InfoType.Asset)
script.Parent.Parent.MaterialPreview.AssetName.Text = asset.Name
script.Parent.Parent.Material.Value = "rbxassetid://" .. script.Parent.Text
end
end
end)
This part changes the StringValue
to the given ID. Which it will be used to be defined as the material
Important lines in the button script:
local newMaterial = script.Parent.Parent.Material.Value -- The string value
RE:FireServer(target, newMaterial) -- Fires a remote event, its arguments are the Mouse target and the material which is the value of that string value
Server script:
game.ReplicatedStorage.Events.materialObjCustom.OnServerEvent:Connect(function(Player, Object, Material)
for i, mat in Object:GetDescendants() do
if mat:IsA("Texture") then
mat.Texture = Material
end
end
end)
This is a very simple feature, but everything is messed up now…
Please help, thanks.