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

(UNSOLVED) How do I make a local script function appear on everyone else's screen?

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

3 comments

0

why not just put the code in a server script?

0

How could I do that with a GUI?

1

You need a RemoteEvent to :FireAllClients and have a local script waiting for the event to occur. If you want here’s an article on RemoteEvents: https://developer.roblox.com/en-us/api-reference/class/RemoteEvent

1 answer

✓ Accepted answer

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.

3 comments

0

I'm confused, sorry. You said for me to call the script "Update your flooderscript to this:"?

0

sorry, mistype lemme fix that

0

im also assumming the second script in your question is called flooderscript

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