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

Why wont my start button work, and count for all players?

script.Parent.MouseButton1Click:Connect(function()
	for i,Player in pairs(game.Players:GetPlayers()) do
		local count = Player.PlayerGui.Start.count
		local Parent = Player.PlayerGui.Start.Start
		count.Visible = true

		Parent.Visible = false
		count.Text = 5
			wait(1)
		count.Text = 4
			wait(1)
		count.Text = 3
			wait(1)
		count.Text = 2
			wait(1)
		count.Text = 1
			wait(1)
		count.Text = "BEGIN!"
	end
	game.Workspace["start part"]:Destroy()
	wait(1)
	game.StarterGui["Start"]:Destroy()
	script.Parent.Parent:Destroy()
end

It's supposed to do that on everyone's screen, but it doesn't. The original worked, but only on the "player who clicked it"'s screen. Why?

2 answers

Please ensure the this isn't in a "localscript" if it is, it will only run for the player who executed the script.

1 comment

0

this won't work bcuz of FilteringEnabled. ServerScripts can't see any descendants of PlayerGui

#Problem The Problem here is that you are using A LocalScript and trying to change something on other Clients (AKA Players). Because of FilteringEnabled this simply won't work. #Solution RemoteEvents is your Answer. For a guide of using RemoteEvents click Here. Basically what you want to do is ##LocalScript

  1. Create a RemoteEvent in ReplicatedStorage
  2. Connect a function to Listen for MouseButton1Click.
    • Which fires the RemoteEvent using RemoteEvent:FireServer()
  3. When RemoteEvent.OnClientEvent is fired do the CountDown ##Normal Script
  4. Connect to the Event RemoteEvent.OnServerEvent
    1. Which fires the Event using RemoteEvent:FireAllClients()
    2. And Destroys start part #Final Script LocalScript
script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.<REMOTE EVENT HERE>:FireServer()
end)

game.ReplicatedStorage.<REMOTE EVENT HERE>.OnClientEvent:Connect(function()
	count.Visible = true
 
        Parent.Visible = false
        count.Text = 5
            wait(1)
        count.Text = 4
            wait(1)
        count.Text = 3
            wait(1)
        count.Text = 2
            wait(1)
        count.Text = 1
            wait(1)
        count.Text = "BEGIN!"

    	wait(1)
	script.Parent.Parent:Destroy()
end)

Server Script

game.ReplicatedStorage.<REMOTE EVENT HERE>.OnServerEvent:Connect(function()
	game.ReplicatedStorage.<REMOTE EVENT HERE>.FireAllClients()
	game.Workspace["start part"]:Destroy()
end)

2 comments

0

Didn't work, despite it looking like it would.

0

Didn't work, despite it looking like it would.

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