I recently made this script, it's basically a core for changing stats from local scripts. The game is Filtering Enabled. When invoked, it'll send over the value it wants to change and what the value is. But whenever valuename is "Health", "Strength", "Speed", "Kagune", "Quinque" it says it's a nil value, the error occured at line 10 i think. Even though there is a value in playerdata. It only seems to work when the valuename is "Playing"
local replicatedstorage = game.ReplicatedStorage local remoteinstance = replicatedstorage:WaitForChild("RemoteInstance") local gamedata = replicatedstorage:WaitForChild("GameData") local remote = remoteinstance:WaitForChild("ChangeStat") --Variables function remote.OnServerInvoke(player, valuename, value) local playerdata = player:WaitForChild("BaseValue") if valuename == "Health" or "Strength" or "Speed" or "Kagune" or "Quinque" then if playerdata:FindFirstChild("SkillPoint").Value > 0 then if gamedata:WaitForChild(valuename).Value > playerdata:WaitForChild(valuename).Value then playerdata:FindFirstChild("SkillPoint").Value = playerdata:FindFirstChild("SkillPoint").Value - 1 playerdata:FindFirstChild(valuename).Value = playerdata:FindFirstChild(valuename).Value + 1 else print("Max Stats!") end end end if valuename == "Playing" then playerdata:WaitForChild(valuename).Value = value else playerdata:WaitForChild(valuename).Value = value end end
One problem that I see straight away is on Line 10:
if valuename == "Health" or "Strength" or "Speed" or "Kagune" or "Quinque" then
Lua does not understand what you put through there, and will automatically return true
.
What you want to do is this:
if valuename == "Health" or valuename == "Strength" or valuename == "Speed" or valuename == "Kagune" or valuename == "Quinque" then
If does not fix your problem, Comment and I'll edit.