Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why isn't this server script running out of studio? Filtering Problem?

It checks if a player has been moved into the storage and then moves them.

while true do
    wait(1)
    if game.ReplicatedStorage.Players.Check.Value == 3 then
        print("No Players Stored")
    elseif game.ReplicatedStorage.Players.Check.Value == 1 then
        print("Player Found")
        game.ReplicatedStorage.Players.Check.Value = 2
        local Location = game.ReplicatedStorage.Players.Player:FindFirstChildOfClass("Part")    
        Location.Parent = game.Workspace.Players
        print("Player Moved")
        game.ReplicatedStorage.Players.Check.Value = 3
    elseif game.ReplicatedStorage.Players.Check.Value == 2 then
        print("Player Move In Progress")
        wait(2)
    end
end

This script renames the part to the players name and then moves it to storage for the above script to move into the Workspace, This 2 step move has to be done as when the below script moves the part it stores it locally preventing players from seeing each other, This is also setting the value for when a part is in there, This is a Local Script.

wait(2)
local Pos = game.Workspace.Spawn.Position
local Player = script.Parent:Clone()
local NM = script.Parent.Parent.NM.Value
	Player.Name = NM
	Player.Parent = game.ReplicatedStorage.Players.Player
	Player.Position = Pos
	game.ReplicatedStorage.Players.Check.Value = 1
	print(NM, "Has been moved")
	wait(5)
script.Parent.Parent.Parent.Controls.ControlMain.Disabled = false
script.Parent.Parent.Parent.Camera.Camera.Disabled = false

1 answer

Properly formatting/indenting code is good practice, as it allows for easier readability which in turn helps debugging. Allow me to help.

while true do
	wait(1)
	if game.ReplicatedStorage.Players.Check.Value == 3 then
		print("No Players Stored")
	else if game.ReplicatedStorage.Players.Check.Value == 1 then
		print("Player Found")
		game.ReplicatedStorage.Players.Check.Value = 2
		local Location = game.ReplicatedStorage.Players.Player:FindFirstChildOfClass("Part")    
		Location.Parent = game.Workspace.Players
		print("Player Moved")
		game.ReplicatedStorage.Players.Check.Value = 3
	else if game.ReplicatedStorage.Players.Check.Value == 2 then
		print("Player Move In Progress")
		wait(2)
		end
		end
	end
end

Now, it's much easier to spot what you did wrong:

  1. else if is not a keyword in Lua. Rather, use elseif.

  2. You added two extra ends at the bottom.

Here's the fixed script.

while true do
	wait(1)
	if game.ReplicatedStorage.Players.Check.Value == 3 then
		print("No Players Stored")
	elseif game.ReplicatedStorage.Players.Check.Value == 1 then
		print("Player Found")
		game.ReplicatedStorage.Players.Check.Value = 2
		local Location = game.ReplicatedStorage.Players.Player:FindFirstChildOfClass("Part")    
		Location.Parent = game.Workspace.Players
		print("Player Moved")
		game.ReplicatedStorage.Players.Check.Value = 3
	elseif game.ReplicatedStorage.Players.Check.Value == 2 then
		print("Player Move In Progress")
		wait(2)
	end
end

Hope I helped!

5 comments

0

Sorry about that i will keep that in mind next time i post, The script still doesn't work, it doesn't print anything and when checking its activity in game it says it isn't active.

0

How ether in studio it works perfectly so any help here would be much appreciated.

0

This is all I can do for how much info you've given.

0

Please wait there ill update it with more scripts that may be relevant, I really need this working thank you for your help!

0

If this isn't enough info i could always allow you to enter my game and take a look.

This discussion is preserved as it was. New answers, comments, and votes are closed.