You can do it however you wish, it’s just that the client should listen for map additions in the workspace and apply changes there only. Changes made elsewhere don’t save/don’t replicate.
Alright, I will try to do that.
So I made amends to the script, and it still doesn’t work. When I moved the map to ReplicatedStorage the game itself worked fine, but the script doesnt. Could you look through it and see what I did wrong?
script.Parent.Frame.LavaAnimation.MouseButton1Click:Connect(function()
if script.Parent.Frame.LavaAnimation.Text == "Lava Animation: On" then
script.Parent.Frame.LavaAnimation.Text = "Lava Animation: Off"
local workspaceMap = game:GetService('Workspace'):WaitForChild('Maps')
-- Loop through maps
while true do
for _, map in pairs(workspaceMap:GetChildren()) do
if (map:FindFirstChild('Lava')) then -- does a child called Lava exist?
if (map.Lava:FindFirstChild('RisingLava')) then -- does a child of Lava called RisingLava exist?
local risingLava = map.Lava:FindFirstChild('RisingLava')
risingLava["Water Texture Script"].Enabled = false
print("it works")
end
end
end
end
elseif script.Parent.Frame.LavaAnimation.Text == "Lava Animation: Off" then
script.Parent.Frame.LavaAnimation.Text = "Lava Animation: On"
end
end)
You can’t disable a server script from the client (for obvious reasons). You should modify the code below to disable particle effects instead of a script.
I don’t really like spoonfeeding, but whatever, I guess?
local frame = script.Parent.Frame.LavaAnimation
local showLavaAnimation = true
local maps = workspace:WaitForChild("Maps")
local function onMapAdded(map)
local lava = map:FindFirstChild("Lava")
if lava and not showLavaAnimation then
-- THIS LINE WILL NEVER WORK BECAUSE YOU ARE TRYING TO
-- DISABLE A SERVER SCRIPT.
-- CHANGE THIS TO THE ACTUAL PARTICLE (PARTICLEEMITTER FOR EXAMPLE).
lava.RisingLava["Water Texture Script"].Enabled = false
end
end
frame.MouseButton1Click:Connect(function()
if showLavaAnimation then
frame.Text = "Lava Animation: Off"
else
frame.Text = "Lava Animation: On"
end
showLavaAnimation = not ShowLavaAnimation
end)
maps.ChildAdded:Connect(onMapAdded)
for _,v in ipairs(maps:GetChildren()) do
onMapAdded(v)
end
Won’t it only find the first lava part? The maps have multiple lava parts.
You should look for all lava parts then by iterating over children.
local function onMapAdded(map)
for _, child in ipairs(map:GetChildren()) do
if child.Name == "Lava" then
-- do something
end
end
end