ASTROCPF
(KingPlatinum)
July 29, 2022, 9:59pm
#1
So, im making a game menu, I have a loading screen for it and whenever the player joins the game it anchors the player’s humanoid root part.
The game menu works whenever you press play but your humanoidrootpart doesn’t get unanchored.
This is what happens:
Here’s the anchor on player join code:
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(Character)
local humrp = Character:FindFirstChild("HumanoidRootPart")
humrp.Anchored = true
end)
end)
Here’s the Button code:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Enabled = false
game.Workspace.anchor.Disabled = true
local humrp = player.Character:FindFirstChild("HumanoidRootPart")
humrp.Anchored = false
end)
can you provide us with the code?
Is the HumanoidRootPart anchored on the server and unanchored from the server as well? If not, that’s your problem.
ASTROCPF:
Here’s the anchor on player join code:
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(Character)
local humrp = Character:FindFirstChild("HumanoidRootPart")
humrp.Anchored = true
end)
end)
Here’s the Button code:
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Parent.Enabled = false
game.Workspace.anchor.Disabled = true
local humrp = player.Character:FindFirstChild("HumanoidRootPart")
humrp.Anchored = false
end)
Anchoring and unanchoring must be done from the server (because of NetworkOwner stuff). Make the unanchoring work on the server and that will fix your problem.
ASTROCPF
(KingPlatinum)
July 29, 2022, 10:03pm
#5
How would I do that?
The Anchor on player join script is a normal script in the workspace, and the button code is a local script in the game menu button
First, you’ll need to use a RemoteEvent. If you don’t know how, please look it up on the DevHub. Fire the RemoteEvent from the client. On the server’s end, unanchor the part. Remember that the first parameter is always the player who fired the RemoteEvent, so use Player.Character.HumanoidRootPart
.
That will fix your anchoring, but you also must remove this line of code:
1 Like
As subtotalant said, you should use a remoteevent to get triggered when the player presses the button.
1 Like
ASTROCPF
(KingPlatinum)
July 29, 2022, 10:09pm
#9
How would I change the script in the servers end??? Please be more clear.
I believe this should help. Press the F1 key while in studio and search up RemoteEvent.
dutycall11
(SavageMode)
July 29, 2022, 10:12pm
#11
Create a script in ServerScriptService
Create a RemoteEvent in ReplicatedStorage
Fire the RemoteEvent when the player presses button
In the server script do this:
local function HumanoidRootPartUnAnchor(player)
player.Character:WaitForChild("HumanoidRootPart").Anchored = false
end)
RemoteEvent.OnServerEvent:Connect(HumanoidRootPartUnAnchor)
make sure to set his answer as the solution
edit: nvm
ASTROCPF
(KingPlatinum)
July 29, 2022, 10:18pm
#14
It works, but when I reset my character it anchors it back, do you know how to fix it?
Edit: All I had to do was disable the anchor script
dutycall11
(SavageMode)
July 29, 2022, 10:21pm
#16
In the server script also do:
game:GetService('Players').PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Died:Connect(function()
character:WaitForChild("Humanoid").Anchored = false
end)
end)
end)
ASTROCPF
(KingPlatinum)
July 29, 2022, 10:21pm
#17
Plus, I’m pretty sure that the script would unanchor the part ONLY when the player dies