So I Have the below script and I have another script that changes the Value of Difficulty depending on the users wishes I know that the value changes because I have gone into the players “Player” and seen that it does change. The script below is part of a larger script but this part only starts once the Value of Difficulty has changed I dont know what is whrong with it but it just wont pick up the updated value of Difficulty. The humand part is the humanoid of a player.
Players
-My Player
–Folder
—Difficulty
File Structure Above and Script Below
`Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty
if Difficulty.Value == "Hard" then
Difficulty = 3
elseif Difficulty.Value == "Medium" then
Difficulty = 2
elseif Difficulty.Value == "Easy" then
Difficulty = 1
print(Difficulty.Value)`
Basically Originally Difficulty = nil then another script turns Difficulty to hard,medium or easy but this script only reads the first value nil not hard,medium or easy
while true do
local torso = findNearestTorso(bin.Position)
if torso~=nil then
Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty
if Difficulty.Value == "Hard" then
Difficulty = 3
elseif Difficulty.Value == "Medium" then
Difficulty = 2
elseif Difficulty.Value == "Easy" then
Difficulty = 1
end
print(Difficulty.Value)
bin.BodyPosition.P = 10000*tonumber(Difficulty)
moveTo(torso)
elseif torso==nil then
bin.BodyPosition.P = 0
end
end
while true do
local torso = findNearestTorso(bin.Position)
if torso~=nil then
Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty
if Difficulty.Value == "Hard" then
Difficulty.Value = 3
elseif Difficulty.Value == "Medium" then
Difficulty.Value = 2
elseif Difficulty.Value == "Easy" then
Difficulty.Value = 1
end
print(Difficulty.Value)
bin.BodyPosition.P = 10000*tonumber(Difficulty)
moveTo(torso)
elseif torso==nil then
bin.BodyPosition.P = 0
end
end
attempt to perform arithmetic (mul) on number and nil
because when Difficuly*10000 The difficulty Value is not hard,medium or easy instead it is nil which it is originally because it doesnt read the updated value
while true do
local torso = findNearestTorso(bin.Position)
if torso~=nil then
Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty
if Difficulty.Value == "Hard" then
Difficulty.Value = 3
elseif Difficulty.Value == "Medium" then
Difficulty.Value = 2
elseif Difficulty.Value == "Easy" then
Difficulty.Value = 1
end
print(Difficulty.Value)
bin.BodyPosition.P = 10000*tonumber(Difficulty.Value)
moveTo(torso)
elseif torso==nil then
bin.BodyPosition.P = 0
end
end
while true do
local torso = findNearestTorso(bin.Position)
if torso~=nil then
Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty
if Difficulty.Value == "Hard" then
Difficulty.Value = "3"
elseif Difficulty.Value == "Medium" then
Difficulty.Value = "2"
elseif Difficulty.Value == "Easy" then
Difficulty.Value = "1"
end
print(Difficulty.Value)
bin.BodyPosition.P = 10000*tonumber(Difficulty.Value)
moveTo(torso)
elseif torso==nil then
bin.BodyPosition.P = 0
end
end
Nope I get the same error as before. The thing that is wrong is that the value doesnt update the Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty part nothing else.
while true do
local torso = findNearestTorso(bin.Position)
if torso~=nil then
Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty
if Difficulty.Value == "Hard" then
Difficulty.Value = "3"
elseif Difficulty.Value == "Medium" then
Difficulty.Value = "2"
elseif Difficulty.Value == "Easy" then
Difficulty.Value = "1"
end
print(Difficulty.Value)
bin.BodyPosition.P = 10000*tonumber(Difficulty.Value)
moveTo(torso)
elseif torso==nil then
bin.BodyPosition.P = 0
end
end
while true do
local torso = findNearestTorso(bin.Position)
if torso~=nil then
Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty
if Difficulty.Value == "Hard" then
Difficulty.Value = "3"
elseif Difficulty.Value == "Medium" then
Difficulty.Value = "2"
elseif Difficulty.Value == "Easy" then
Difficulty.Value = "1"
end
print(Difficulty.Value)
bin.BodyPosition.P = 10000*tonumber(Difficulty.Value)
moveTo(torso)
elseif torso==nil then
bin.BodyPosition.P = 0
end
end
The thing that is wrong is that the value doesnt update the Difficulty = (game.Players:GetPlayerFromCharacter(human.Parent)).Folder.Difficulty part nothing else.
It is originally Nil until a person updates it to hard,medium,easy and i know that it updates to hard,medium,easy but this script only picks up the original value nil