Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago
Edited 5 years ago

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

0
why not just put the code in a server script? ryan32t 306 — 5y
0
How could I do that with a GUI? happyhal75 32 — 5y
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 123nabilben123 499 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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.
0
I'm confused, sorry. You said for me to call the script "Update your flooderscript to this:"? happyhal75 32 — 5y
0
sorry, mistype lemme fix that throwawayaccount2001 102 — 5y
0
im also assumming the second script in your question is called flooderscript throwawayaccount2001 102 — 5y
Ad

Answer this question