Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does Remote Function not seem to change value?

Asked by 7 years ago

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
0
Nevermind the error occured at Line 12. xXOverLord34Xx 8 — 7y
0
It also seems like it does subtract one SkillPoint xXOverLord34Xx 8 — 7y
0
where is the link that calls for ur function? personal_ly 151 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

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.

0
That fixed the problem! I also added in some elseifs but yea it's fixed! Thanks alot :D xXOverLord34Xx 8 — 7y
Ad

Answer this question