Hi guys! So I made a script, if the player joins to the game they cant move, because the HumanoidRootPart is anchored by a local script in StarterPlayerScripts. All I want is to check if the player is pressed on the Play button, and if its true, the HumanoidRootPart.Anchored = false.
Heres the codes, and the structure of the objects:
local player = game.Players.LocalPlayer
local letsMove = game.StarterGui.TeamGui.Enabled
player.CharacterAdded:Connect(function(character)
character:WaitForChild("HumanoidRootPart").Anchored = true
if letsMove == false then
character:WaitForChild("HumanoidRootPart").Anchored = false
end
end)
And for the main menu screen this is the structure for it:
As I said, if the player joins to the game they cant move, because they’re on the Main Menu screen, and the movement is disabled by just a script, where the HumanoidRootPart is anchored. And what I want:
A script which checks, if the player pressed on the Play button. And if the player pressed the play button, then the HumanoidRootPart is not anchored anymore for him.
-- You can do as much as possible, so i'm doing 1 Parent because if you want to make the script touching the screengui the it's on the 2nd line.
script.Parent.Enabled = false -- You can do true...
if not script.Parent.Enabled == true then
while task.wait(0.02) do
warn("The Gui isn't visible")
end
end
if not script.Parent.Enabled == false then
print("The Gui is visible")
end
I’m not the best at explaining, but I’ll try my best.
You want to start by adding a “RemoteEvent” in ReplicatedStorage. Name it whatever you want.
Then, use this code in a LocalScript inside of the start button:
script.Parent.MouseButton1Click:Connect(function()
game.ReplicatedStorage.RemoteEvent:FireServer() -- Replace RemoteEvent with you RemoteEvent's name
end)
This sends a message through the RemoteEvent to the server. Now we have to pick it up with the server.
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr) -- When firing a RemoteEvent from a client, the first variable (I'm calling it "plr") is the player that sent the event
plr.Character:WaitForChild("HumanoidRootPart").Anchored = false
end)