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

Why am I not picking up anything in the output?

Asked by 4 years ago

Okay so essentially I am saying if there is no such thing as the gravity controller then reload the character.

if not game.ReplicatedStorage:FindFirstChild("GravityController") then  
    game.Players.PlayerAdded:connect(function(player)
        wait(1)
    player:LoadCharacter()
    print("Player.Name..was Refreshed")
    end)
end
0
PlayerAdded only fires when the player joins the game. Rheines 661 — 4y
0
Try switching line 1 and 2 dualworlds 90 — 4y
0
yeah but the gravity controller is not destroyed yet so how could it run? Nistrict 44 — 4y
0
Also is this in a local script or server script. JesseSong 3916 — 4y
View all comments (2 more)
0
local Nistrict 44 — 4y
0
You have to always check if the gravity controller is missing. If it is then reload the character, and break the loop. You could use a while loop or a repeat until loop. killerbrenden 1537 — 4y

2 answers

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

This is because your not supposed to add a wait when the player joins because the player will already have joined within 0 seconds.WaitForChild

game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
        local humanoid = character:FindFirstChild("Humanoid")

if not game.ReplicatedStorage:WaitForChild("GravityController") then  
    player:LoadCharacter()
    print("Player.Name..was Refreshed")
    end)
end
0
I am not talking about when the player joins I am talking about if the gravity controllerscript is not there then it will refresh the player Nistrict 44 — 4y
0
Put your script in StarterPlayerScript JesseSong 3916 — 4y
Ad
Log in to vote
0
Answered by
Mayk728 855 Moderation Voter
4 years ago
game:GetService('Players').PlayerAdded:Connect(function(plr)
    if not game:GetService('ReplicatedStorage'):FindFirstChild('GravityController') then
        wait(1)
        plr:LoadCharacter()
        print(plr.Name..' was refreshed!')
    end
end)

Answer this question