This is a server script btw
pos = script.Parent
Frame = game.StarterGui.PosPicker.Frame
Player = game.Players.LocalPlayer
function pos(clicked)
Player.Character.IsHomeCenter.Value = true
Frame.Visible = false
end
pos.MouseButton1Down:connect(pos)
This is a server script btw
pos = script.Parent
Frame = game.StarterGui.PosPicker.Frame
Player = game.Players.LocalPlayer
function pos(clicked)
Player.Character.IsHomeCenter.Value = true
Frame.Visible = false
end
pos.MouseButton1Down:connect(pos)
There are several issues with this. Firstly, Scripts—formally recognized as ServerScripts—aren't meant to operate on the Client, which means they won't run to start with. To control the local machine, we use LocalScripts. Make sure to convert to one.
Secondly, StarterGui is not the container that actually handles the Users' Interfaces, this is simply a Server container meant to preview the UI to the Developer, and load in the UI to the Player when they join. Think of it like StarterPack and Backpack's relationship. To actually reference the real GUI, we need to call PlayerGui.
You'd want to be using the .MouseButton1Click signal in this scenario. This event will launch when the Player releases their left trigger on a GUI, resulting in an actual Click, whilst 1Down will just fire regardless if the trigger is raised. The 1Click signal will also ensure the click occurs within the bounds of the GUIObject.
Lowercase :connect() is deprecated, it is asked of programmers to use :Connect() in further projects.
local Player = game:GetService("Players").LocalPlayer
local PlayerGui = Player:WaitForChild("PlayerGui")
local PosPicker = PlayerGui:WaitForChild("PosPicker")
local Frame = PosPicker:WaitForChild("Frame")
local Pos = script.Parent
local function Pos()
local Character = Player.Character or Player.CharacterAdded:Wait()
local IsHomeCenter = Character:FindFirstChild("IsHomeCenter")
if (IsHomeCenter) then
IsHomeCenter.Value = true
Frame.Visible = false
end
end
Pos.MouseButton1Click:Connect(Pos)
This discussion is preserved as it was. New answers, comments, and votes are closed.
4 comments
this script does not work anyways
That is because I made a slight reference mistake, something you should've caught. Please try once more.
I did see the pospicker mistake
Alright, my apologies for the accusation then. Have you converted to a LocalScript?