So I have this code below:
local DSS = game:GetService("DataStoreService")
local ForcePowersDS = DSS:GetDataStore("ForcePowers")
local ForcePowersTable = {
{
Name = "hasForceJump",
Value = false
},
{
Name = "hasForceSpeed",
Value = false
},
{
Name = "hasForceHeal",
Value = false
}
}
game.Players.PlayerAdded:connect(function(player)
local FS = Instance.new("Model",player)
FS.Name = "ForceStats"
local hasForceJump = Instance.new("BoolValue",FS)
hasForceJump.Name = "hasForceJump"
hasForceJump.Value = false
local hasForceSpeed = Instance.new("BoolValue",FS)
hasForceSpeed.Name = "hasForceSpeed"
hasForceSpeed.Value = false
local hasForceHeal = Instance.new("BoolValue",FS)
hasForceHeal.Name = "hasForceHeal"
hasForceHeal.Value = false
local fpt = ForcePowersDS:GetAsync(player.userId.."_forceStats")
if fpt then
hasForceJump.Value = fpt[1].Value
hasForceSpeed.Value = fpt[2].Value
hasForceHeal.Value = fpt[3].Value
if hasForceJump.Value == true then
local ForceJumpActive = Instance.new("BoolValue",player)
ForceJumpActive.Name = "ForceJumpActive"
ForceJumpActive.Value = true
end
local JV = Instance.new("IntValue",player)
JV.Name = "JumpValue"
JV.Value = player.Character.Humanoid.JumpPower
if hasForceSpeed.Value then
local ForceSpeedActive = Instance.new("BoolValue",player)
ForceSpeedActive.Name = "ForceSpeedActive"
ForceSpeedActive.Value = true
local sVal = Instance.new("IntValue",player)
sVal.Name = "SpeedValue"
sVal.Value = player.Character.Humanoid.WalkSpeed + (10 * player.leaderstats.Lvl.Value)
end
if hasForceHeal.Value then
local hvalue = Instance.new("IntValue",player)
hvalue.Name = "HealValue"
hvalue.Value = (player.leaderstats.Lvl.Value * 10)
end
player.CharacterAdded:connect(function(c)
if player.ForceStats.hasForceJump.Value then
player.Character.Humanoid.JumpPower = player.Character.Humanoid.JumpPower + (10 * player.leaderstats.Lvl.Value)
local JV = Instance.new("IntValue",player)
JV.Name = "JumpValue"
JV.Value = player.Character.Humanoid.JumpPower
game.ReplicatedStorage.RemoteService.ShowDialog:FireClient(player,player.Name,player.Name .. " has the power of force jump!",2)
end
if player.ForceStats.hasForceSpeed.Value then
player.Character.Humanoid.WalkSpeed = player.SpeedValue.Value
local m = Instance.new("Message",game.Workspace)
m.Text = player.Name .. " has the power of force speed!"
wait(5)
m:Destroy()
end
if player.ForceStats.hasForceSpeed.Value then
local hvalue = Instance.new("IntValue",player)
hvalue.Name = "HealValue"
hvalue.Value = (player.leaderstats.Lvl.Value * 10)
local m = Instance.new("Message",game.Workspace)
m.Text = player.Name .. " has the power of force heal!"
wait(5)
m:Destroy()
end
end)
else
print("Starting out with the Force...")
end
local ForceStats = Instance.new("IntValue",player)
ForceStats.Name = "ForceStats"
local fpt = ForcePowersTable
ForcePowersDS:SetAsync(player.userId.."_forceStats",fpt)
for _,v in pairs(fpt) do
local forcestat = Instance.new("BoolValue",ForceStats)
forcestat.Name = v.Name
forcestat.Value = v.Value
end
game.ReplicatedStorage.RemoteService.Unlock.OnServerEvent:connect(function(player,forcePower)
if forcePower == "ForceJump" then
fpt[1].Value = true
local JumpValue = Instance.new("IntValue",player)
JumpValue.Name = "JumpValue"
JumpValue.Value = 50 + (10 * player.leaderstats.Lvl.Value)
elseif forcePower == "ForceSpeed" then
fpt[2].Value = true
elseif forcePower == "ForceHeal" then
fpt[3].Value = true
end
ForcePowersDS:SetAsync(player.userId.."_forceStats",fpt)
end)
end)
but it gives me this error?
ServerScriptService.ForcePowers:36 attempt to index '?' a nil value
What gives?
