What do you want to achieve?
~ I want a text button that only I can see.
What is the issue?
~ In studio test play with multiple players, no one has the button.
If I publish the game and drop myself and my alt in, both of us have the button.
What solutions have you tried so far?
~ Tried searching but not really getting anywhere.
As far as I can tell, I should be the only one that sees the button.
Here is the script…
local button = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ActivateGlobalParticleEmitter")
for i, v in pairs(game.Players:GetPlayers()) do
if v.Name == "LottaPitchy" then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
button.MouseButton1Click:Connect(function()
remoteEvent:FireServer(player)
end)
end
The button is set to visible - false in properties.
It was set to true, but that was still the same.
Instead of trying to loop through the players, you should instead make use of
game.Players.LocalPlayer
To get what you want, you should be able to do:
local button = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ActivateGlobalParticleEmitter")
if game.Players.LocalPlayer.Name == "LottaPitchy" then
script.Parent.Visible = true
else
script.Parent.Visible = false
end
button.MouseButton1Click:Connect(function()
remoteEvent:FireServer(player)
end)
Couple of points regarding this:
The addition of the else script.Parent.Visible = false end is probably not neccesary, but I added it just in case you forget to change the visibility to false in Studio.
Instead of going off of username, you should go off of UserId in case you end up changing your username on Roblox. However, for now it should be fine.
Ensure that you either check that the person who fired the remote event is yourself (so exploiters can’t triger it).
In the future, you should instead clone the UI from a server location to the PlayerGUI if the player is yourself, so that exploiters can’t make the UI visible and access it.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ActivateGlobalParticleEmitter")
task.wait()
if game.Players.LocalPlayer.Name == "LottaPitchy" then
button.Visible = true
else
end
button.MouseButton1Click:Connect(function()
remoteEvent:FireServer(player)
end)
should work, you dont need to loop, I believe the loop is going through every player, eventually running the loop through your name on other players client making it visible for others, localplayer is the easiest way to do this though.
if game.Players.LocalPlayer.UserId == "BunchOfNumbersHere" then
?
I’m so bad at scripting.
~ The button is set to false already, but I’ll leave that in in case I have a “moment” and forget it’s SUPPOSED to be false.
~ Are exploiters going to cause an issue? Like, if an exploiter gets in, is the worst thing they’re going to do there the equivalent of pressing the button? If so all they’re going to do is start a particle emitter at the wrong time which will be annoying but not a disaster.
I should look more into how to do this I think, to protect future endeavours.
local button = script.Parent
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("ActivateGlobalParticleEmitter")
if game.Players.LocalPlayer.Name == "LottaPitchy" then
script.Parent.Visible = true
end
button.MouseButton1Click:Connect(function()
remoteEvent:FireServer(player)
end)
I have no errors or warnings in the output, but the button is not visible.
(player) in the last line has a red squiggle under it, if that’s relevant…?
add the task.wait() at the top so it makes sure the script runs when stuff loads, you can make it task.wait(2) to be sure, also player is underlined because you haven’t defined the variable. if i remember correctly player is an automatic parameter, meaning you dont have to add the player its automatically added to the remoteevent.OnServerEvent() or whatever the function is