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

I can't hide or destroy a gui with filteringenabled on???

Asked by 6 years ago
Edited 6 years ago

You see, I've been making a main menu gui and the teleporting works and team changing etc. However, when I try to hide the gui so the player can actually play, it doesn't do anything. My local script is inside the gui so I figured that if I try hide the gui it'll also disable the script that lets the team changing script work. I'm not exactly sure where to place my local script either as filteringenabled doesn't let you use LocalPlayer. I'll provide the scripts. Local Script:

local event = game:GetService("ReplicatedStorage"):WaitForChild("StartMenu")
script.Parent.MouseButton1Down:connect(function()
    game.ReplicatedStorage.StartMenu:FireServer() --StartMenu is a RemoteEvent.
end)

Normal Script (located in serverscriptservice):

local event = game:GetService("ReplicatedStorage"):WaitForChild('StartMenu')
event.OnServerEvent:connect(function(player)
    print("Someone pressed the button!")
    player.TeamColor = BrickColor.new("Persimmon")
    player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(15.31,85.839,32.044))
    player.Character.Humanoid.JumpPower = 50
    player.Character.Humanoid.WalkSpeed = 16
    player.PlayerGui.MenuStart.Enabled = false --Renamed to avoid confusion.
end)

2 answers

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

The server cannot access a UI, because a UI is on the computer (client) and the server is in the roblox's server. The roblox's server is not your computer. You should put the script that changes the UI in a localscript.

0
If I put it in a localscript I'd get the error 'OnServerEvent can only be used on the server'. TheDevProgram 2 — 6y
0
No, the editing the UI part, not the rest of script. Can you please make a little common sense? hiimgoodpack 2009 — 6y
Ad
Log in to vote
-1
Answered by
thesit123 509 Moderation Voter
6 years ago

The argument player is just a string. Try this:

local event = game:GetService("ReplicatedStorage"):WaitForChild('StartMenu')
event.OnServerEvent:connect(function(plr)
    local player = game:GetService("Players"):FindFirstChild(plr) -- Look for player with the name in plr

    player.TeamColor = BrickColor.new("Persimmon")
    player.Character.HumanoidRootPart.CFrame = CFrame.new(Vector3.new(15.31,85.839,32.044))
    player.Character.Humanoid.JumpPower = 50
    player.Character.Humanoid.WalkSpeed = 16
    player.PlayerGui.MenuStart.Enabled = false --Renamed to avoid confusion.
end)
0
OnServerEvent passes the player object as the first arg, it is not a string. User#5423 17 — 6y
0
@kingdom5, Well, My bad, got confused. thesit123 509 — 6y

Answer this question