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

GUI cloning into every player's PlayerGui instead of individual?

I have encountered this problem before. The problem I'm facing is whenever I click on the part with a ClickDetector, the GUI shows up on every player's screen instead of the player who clicked it. This inside of a LocalScript and StarterGui.

shop = game.Players.LocalPlayer.PlayerGui.Shop

frame = shop:WaitForChild("Frame")

exitButton = frame:WaitForChild("ExitShop")

Player = game.Players.LocalPlayer

Alexis = game.workspace.Alexis

Clicker = Alexis.Torso:WaitForChild("ClickDetector")

ShopSound = shop:WaitForChild("ShopSound")
--------------------
Clicker.MouseClick:connect(function(playerWhoClicked)
	ShopSound:Play()
	frame:TweenPosition(UDim2.new(0.5,-250,0.5,-200), "In", "Quint", 0.35, true)
	Player.DevComputerMovementMode = "Scriptable"
end)

--Do stuff when the exit button is clicked
exitButton.MouseButton1Down:connect(function()
	ShopSound:Play()
	frame:TweenPosition(UDim2.new(0.5,-250,0.5,300), "Out", "Quint", 0.35, true)

--Give control back to the player
	Player.DevComputerMovementMode = "UserChoice"
end)

1 comment

0

This does not have anything on cloning the Gui into a player. Since it's in a LocalScript, this should not affect anyone else. Bad question. Also, use the playerWhoClicked if you're gonna define it.

1 answer

Note: I am a beginner scripter, this will more than likely be incorrect, but maybe. You're making it move, which will move it on everybody's gui, what i do, is if it isnt like a animation to come in, i just make the visible off, and make it visible when they click on it, my solution: If it isn't an animation when it comes in, make it invisible at the start, then change its visible when they click on it.

function onClicked()
if script.Parent.Frame.Visible == true then
	script.Parent.Frame.Visible = false
	else
	script.Parent.Frame.Visible = true
	end
end
script.Parent.Button.MouseButton1Click:connect(onClicked)

Just an example script :)

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