One button Multiplayer Game with Screen changing

  1. I wanna create a multiplayer game where only one button can be touched by everyone and a screen (another part with SurfaceGui) connected to it changes some sort of number or text (just an idea) when touched.

    I noticed a problem when 2 players use the same pad and just one player touches the pad the SurfaceGui changes for the other player aswell (What I don’t want to have).

  2. Here is a picture as example:

  3. I tried using LocalScript (Never used it before and didn’t had ideas what it will change)
    Changing properties of every part, script, Gui etc.
    Looked through a lot of YouTube videos (dumb idea)
    Was online if somebody has asked the question before or similar
    Games that has the kind of construct… were asked if they could help me (none of them did)

Here is a free script which I used:

local part = script.Parent.Parent:WaitForChild("Counter")
local screen = part.NumberHolder:WaitForChild("ScreenNumber")
local rando =  script.Parent

rando.touched:connect(function()
	
	rando.CanTouch = false
	rando.CanCollide = false
	rando.Color = Color3.fromRGB(206, 0, 0)
	local a = math.random(1,10)
	screen.Text = "Number: " ..a
	
	
	wait(0.125)
	
	rando.CanTouch = true
	rando.CanCollide = true
	rando.Color = Color3.fromRGB(0, 255, 0)
	
end)

And the Explorer for free aswell:
image
Btw. the pad (NumberChanger) is automated while not moving the character.

I read that you used a local script, but did you put that in workspace? Localscripts don’t work in workspace.
To be clear here: a localscript is obviously your answer, as they only change things for the client(player), not the entire server
You would need to place a local script in starterplayerscripts and pste the code in there

1 Like

I actuall tried it inside StarterPlayerScript and worked but it has not change anything from what I wanted.
I can give the Localscript that I have:

local part = game.workspace.AutoNumberChangeBox:WaitForChild("Counter")
local screen = game.workspace.AutoNumberChangeBox.Counter.NumberHolder:WaitForChild("ScreenNumber")
local rando =  game.workspace.AutoNumberChangeBox:WaitForChild("NumberChanger")

rando.touched:connect(function()

	rando.CanTouch = false
	rando.CanCollide = false
	rando.Color = Color3.fromRGB(206, 0, 0)
	local a = math.random(1,9)
	screen.Text = "Number: " ..a


	wait(0.125)

	rando.CanTouch = true
	rando.CanCollide = true
	rando.Color = Color3.fromRGB(0, 255, 0)

end)
1 Like

Wait a minute, can you place your normal script, not the local one, in the surfacegui instead of outside of it?

I did that but I have to change it because the properties are now on a different path
which leads me when I play this script inside SurfaceGui (NumberHolder) it gives me after touching the pad an infinite yield warning.

Then dont use waitforchild, its not needed

I actually don’t wanna have the 2nd player see the output of the 1st player using the pad.

The 2nd player should be seeing “Press the Button” (for example) while joined the game and not the output from other players.
And I rewrote the script for being inside SurfaceGui. (did not change)

1 Like

The color next to the print is blue, that means its printing on the client side, a client cannot see other clients prints

1 Like

Which means when it’s inside the Game it’s not visible by others?
And is there a better difference between to have a visible one and not with scripts?