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

How does one make the script work properly for specific players?

I'm currently trying to make a script for summoning an orb near the shoulder of the character to be specific to myself, and later others, but I can't tell if I have something in the wrong place or if I need to separate it to be a remote event. The script sits in the workspace and works without these lines:

local Soul = {"Athena1100"}

for i,child in pairs(Soul) do
if string.lower(child) == string.lower(name) then

but the full script is:

local Soul = {"Athena1100"}

game.Players.PlayerAdded:connect(function(Player)
	Player.CharacterAdded:connect(function(Character)

for i,child in pairs(Soul) do
if string.lower(child) == string.lower(name) then
		local Orb = Instance.new("Part", Character)
		Orb.BrickColor = BrickColor.new("Light stone grey")
		Orb.Material = "Neon"
		Orb.Size = Vector3.new(.30, .30, .30)
		Orb.Anchored = false
		Orb.CanCollide = false
		local Mesh = Instance.new("SpecialMesh", Orb)
		Mesh.MeshType = "Sphere"
		local BP = Instance.new("BodyPosition", Orb)
		BP.MaxForce = Vector3.new(10000, 10000, 10000)
		while wait() do
			BP.Position = Character:FindFirstChild("Torso").CFrame * CFrame.new(2, 2, 1.4).p
		end
	end)
end)

with the full script, it will not load the sphere, but without the three lines it loads just fine.

2 comments

0

What's the issue?

0

The issue is that it will not load if it's set up to find a specific player.

1 answer

local Soul = {"Athena1100"}
game.Players.PlayerAdded:connect(function(Player)

for i,v in pairs(Soul) do
	if string.lower(Child) == (string.lower(Player.Name)) then
	-- do stuff lol
end
end
end)

if that does not work do this

local Soul = {"Athena1100"}
game.Players.PlayerAdded:connect(function(Player)

for i,v in pairs(Soul) do
	if Player.Name == v then -- why do you need a lower if you wrote the exact name?
	-- do stuff lol
end
end
end)

--if this script does not work either do this and delete the above
-[[ -- if you are using this code remove this
local Soul = {"Athena1100"}
local Player = game:GetService("Players").LocalPlayer

for i,v in pairs(Soul) do
	if Player.Name == v then
	-- do stuff lol
end
end
end)
]] -- and also remove this

also not tested obviusly

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