Hello all. I have a flag system (utilising meshes in a tool) where you can change the texture via clicking a button. It works, but not how I intended. It only changes the texture client side not server side. I am utilising a local script (Shown below.) I have tried getting the flag tool using script.Parent but it had a meltdown toing that. This is my layout!
local player = game.Players.LocalPlayer.Name
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local flag = game.Workspace:FindFirstChild(player):WaitForChild("Flag")
local AnimatedFlag = flag:WaitForChild("Handle"):WaitForChild("Model"):WaitForChild("AnimatedFlag"):WaitForChild("Flag")
local AnimFlagParts = AnimatedFlag:GetDescendants()
local FlagTex = require(ReplicatedStorage.FlagTextures)
local GreenButton = container.Green.TextButton
local YellowButton = container.Yellow.TextButton
local RedButton = container.Red.TextButton
local BlueButton = container.Blue.TextButton
local WarningButton = container.Warning.TextButton
local BlackButton = container.Black.TextButton
local CheckeredButton = container.Finished.TextButton
local RYSButton = container.Track.TextButton
local WhiteButton = container.White.TextButton
local function find()
if not script.Parent.Parent:FindFirstChild("Credits") then
script.Parent.Parent.Parent:Destroy()
end
end
GreenButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.Green
end
end
end)
YellowButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.Yellow
end
end
end)
RedButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.Red
end
end
end)
BlueButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.Blue
end
end
end)
WarningButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.Warning
end
end
end)
BlackButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.Black
end
end
end)
CheckeredButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.Checkered
end
end
end)
RYSButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.SlipperyTrack
end
end
end)
WhiteButton.MouseButton1Click:Connect(function()
for _, descendants in pairs(AnimFlagParts) do
if descendants:IsA("MeshPart") then
descendants.TextureID = FlagTex.White
end
end
end)```