I'm trying to make a GUI that floods the entire map. I have the scripting done, I just need to make it so everyone can see it, not just the person who used the GUI if that makes any sense. Here are the 2 scripts I am using: Part creator:
function onclick() local character = script.Parent.Parent.Parent.Parent.Character local p = Instance.new("Part") local posX = character.LowerTorso.Position.X local posY = character.LowerTorso.Position.Y local posZ = character.LowerTorso.Position.Z p.Anchored = true p.CanCollide = false p.Name = "Flooder" p.Material = "SmoothPlastic" p.Transparency = 0.5 p.BrickColor = BrickColor.new("Light blue") p.Parent = game.Workspace p.Position = Vector3.new(posX-0,posY-2,posZ-5) p.Size = Vector3.new(1024,20,1024) --change to map size (middle determines the height of the water) end script.Parent.MouseButton1Click:Connect(onclick)
Flooder:
function onclick() game.Workspace.Terrain:FillBlock(game.Workspace.Flooder.CFrame, game.Workspace.Flooder.Size, Enum.Material.Water) game.Workspace.Flooder:Destroy() end script.Parent.MouseButton1Click:Connect(onclick)
Any help would be appreciated! Thanks! :D
I assume the FlooderScript is supposed to be clicked after the part is made. In that case, make a RemoteEvent
in ReplicatedStorage
then update your FlooderScript to this:
function onclick() game.ReplicatedStorage.<Remote event name here>:Fire(game.Workspace.Flooder) -- We access the remote event and fire it passing the parameter of the Flooder Part. Firing a remote event sends the info to the server, so the server can then do the logic. end script.Parent.MouseButton1Click:Connect(onclick)
Next, we make a ServerScript
and put the following code in it:
function floodcommand(flooder) game.Workspace.Terrain:FillBlock(flooder.CFrame, flooder.Size, Enum.Material.Water) flooder:Destroy() -- Same commands you did just on the server end game.ReplicatedStorage.<Remote event name here>.OnServerFire:Connect(flooder) -- When the player sends the message to flood the game using the top script, the server recieves the command using the OnServerFire event, and we pass through the event the flooder variable, which we use to make the flood.