I am trying to add an aura script to the player whenever the player spawns if their datastore value of hasShock is true. I've tried a ton of different things but nothing seems to be working.
local Players = game:GetService("Players")
local shock
tool = game.Lighting:findFirstChild("LightningAura")
local function onCharacterAdded(character)
if(shock == true) then
print("this works")
else
print("still works")
end
end
Players.PlayerAdded:Connect(function(Player)
shock = Player.pscripts.hasShock.Value
if(Player.pscripts.hasShock.Value == true) then
local a = tool:clone()
a.Parent = Player.Character
else
print("Player doesn't have shock")
end
end)
That's the first thing I tried but it always said the player doesn't have shock.
tool = game.Lighting:findFirstChild("LightningAura") -- Put the name of your tool here.
game.Players.PlayerAdded:Connect(function(player)
local pscripts = Instance.new("Folder")
pscripts.Name = "pscripts"
pscripts.Parent = player
local hasShock = Instance.new("BoolValue")
--Change below for name
hasShock.Name = "hasShock"
-- Default value
hasShock.Value = false
hasShock.Parent = pscripts
--Again name and default
local hasSSJ = Instance.new("BoolValue")
hasSSJ.Name = "hasSSJ"
hasSSJ.Value = false
hasSSJ.Parent = pscripts
player.CharacterAdded:Connect(function(Character)
Character:WaitForChild('Humanoid').Died:Connect(function()
print("dead")
local a = tool:clone()
if(hasShock.Value == true) then
print("Got this far")
local a = tool:clone()
a.Parent = player.Character
end
end)
end)
end)
This is the second thing I tried. It got to the got this far print statement every time but it didn't get put in the players inventory. Is there another way to do this? Or is there a way to fix one of the other ones.

1 comment
Thanks so much! This helped!