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

Ko Sword Giver

I need help on how to make a script on how to make a Sword Giver that only works on a number of KOs, should i use a local script or a Regular Script?

3 answers

Since there is really no reason to use a LocalScript here, I would use a Script instead. You can learn when and how to use a LocalScript here.

Assuming that you want the user that touches the button to get all the swords they are eligible for, you would do something like this:

local swords = { --Keep swords in a model called "Swords" and put the model inside of Lighting. Make sure the strings in this table are the same as the swords name.
--	[KOs] = "Sword Name"
	[0] = "Classic Sword";
	[10] = "Venomshank"
}

local swordGiver = script.Parent

swordGiver.Touched:connect(function(hit)
	local character = hit.Parent
	local player = game.Players:GetPlayerFromCharacter(character)
	if player and not character:FindFirstChild("HasSword") then
		local kos = player.leaderstats.KOs.Value
		for req, sword in pairs(swords) do
			if kos >= req then
				game.Lighting.Swords[sword]:clone().Parent = player.Backpack
			end
		end
		Instance.new("ObjectValue", character).Name = "HasSword"
	end
end)

In order for the character to update/receive the swords that they are eligible for they must reset their character because the "HasSwords" ObjectValue needs to be removed (from their character.)

Hope this helps!

1 comment

0

Ill try this

Just do this, get a leaderboard, get the gui like Firebrand:100 kos Swordcane: 5 those kind of things in startergui, then put all the swords you have in lightning (The ones that are in the gui like firebrand,swordcane insert that and put it in lightning

Try something like this.

requiredkos = 0
script.Parent.Touched:connect(function(h)
	if h.Parent:findFirstChild("Humanoid") then
		local human = h.Parent:findFirstChild("Humanoid")
		
		if human.Health > 0 then
			local p = game.Players:GetPlayerFromCharacter(human.Parent)
			
			if p:findFirstChild("leaderstats") then
				local kos = p:findFirstChild("KOs")
				
				if kos and kos.Value > requiredkos then
					--give them the sword
				end
			end
		end
	end
end)

1 comment

0

Im trying to make one for like 10 Kos = VenomShank and so on

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