I’m making yet another Naruto game and I want it to be similar to Shindo Life. Im trying to save and load chakra natures but I can’t figure it out. Im trying to have a value in the character. It can read and load the ui perfectly fine, but when I try to change the value it says “attempt to index nil with ‘Value’”
-Thanks
That’s because you’re trying to access something that doesn’t exist.
Is the value made in a LocalScript and referenced from a ServerScript?
I need the code to see what your problem is.
Sorry if the code is messy
Local Script
local ChakraList = {
"Fire",
"Wind",
"Lighting",
"Earth",
"Water"
}
local ChakraImageList = {
"rbxassetid://10159036956",
"rbxassetid://10159056103",
"rbxassetid://10159057422",
"rbxassetid://10159054958",
"rbxassetid://10159052292"
}
local canSpin = true
local char = game.Players.LocalPlayer.Character
local elem1 = char:WaitForChild("Element1").Value
local elem2 = char:WaitForChild("Element2").Value
if char and elem1 ~= 0 then
script.Parent.Text = tostring(ChakraList[char.Element1.Value])
script.Parent.Parent.Image = ChakraImageList[char.Element1.Value]
end
script.Parent.MouseButton1Click:Connect(function()
if canSpin == true then
canSpin = false
local randomNum = math.random(1, #ChakraList)
local chakraType = ChakraList[randomNum]
local image = ChakraImageList[randomNum]
script.Parent.Text = tostring(chakraType)
script.Parent.Parent.Image = image
script.Parent.Parent.Parent.Parent.UpdateChar:FireServer(char, 1, randomNum)
wait(1)
script.Parent.Text = "[SPIN]"
canSpin = true
end
end)
Script
script.Parent.UpdateChar.OnServerEvent:Connect(function(char, elem, num)
if elem == 1 then
char:FindFirstChild("Element1").Value = num
else
char:FindFirstChild("Element2").Value = num
end
end)
Nevermind! I was trying to find the Element Value from the player and not the Character! Ha!