Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How can i make this much simpler?

-- Script 1
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Swords = ReplicatedStorage:FindFirstChild('Swords')
game.Workspace.ChildAdded:connect(function(plr)
if plr:IsA("Player") then
local RewarableScript = script:WaitForChild('Rewardable')
RewarableScript:Clone().Parent = plr
plr:FindFirstChild('Rewardable').Disabled = false
end
end)

-- Script 2 
local Humanoid = script.Parent.Humanoid 
function Death() 
local tag = Humanoid:findFirstChild("creator") 
	if tag ~= nil then 
		if tag.Value ~= nil then 
local leaderstats = tag.Value:findFirstChild("leaderstats") 
if leaderstats ~= nil then 
leaderstats.Lvl.Value = leaderstats.Lvl.Value + 1
wait(0.1)
script:remove()
			end 
		end 
	end 
end 

Humanoid.Died:connect(Death) 

1 comment

0

This is already pretty simple. Instead of just pasting your code, explain what you mean and what you need help with.

1 answer

✓ Accepted answer

I don't know what you were trying to accomplish, so I just rewrote the format for you so you can do what you want with it:

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local Swords = ReplicatedStorage:FindFirstChild('Swords')

game.Players.PlayerAdded:connect(function(Player)
	-- Everytime a player joins the game, set up these connections

	-- Create leaderstats here


	Player.CharacterAdded:connect(function(Character)
		-- Stuff you do every time the Player respawns
		

		Character:WaitForChild("Humanoid").Died:connect(function()
			-- Stuff you do every time the Player dies

			local tag = Humanoid:FindFirstChild("creator") 
			if tag and tag.Value then 
				local leaderstats = tag:FindFirstChild("leaderstats") 
				if leaderstats then
					leaderstats.Lvl.Value = leaderstats.Lvl.Value + 1
				end
			end

		end)

	end)
	
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.