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

How do I make sword givers like the ones in SFOTH?

I'm working on my PVP game which is based off of SFOTH, but I want to add anchored gear givers around the map. How do I do this?

1 comment

2

I think you need scripts to do it.

1 answer

you can use touch events to see if the thing touching the part is a player then if it is a player, clone a sword into the backpack

make sure you have a sword named mySword in the replicated storage and a part named SwordGiver in the workspace.

part = game.Workspace.SwordGiver --this is a reference to the part that you touch that gives you the sword

sword = game.ReplicatedStorage.mySword --this is a reference to the sword you want to give the player

--touch event that runs whenever a player touches a part
part.Touched:Connect(function(hit)
	local player = game.Players:FindFirstChild(hit.Parent.Name)
	--check if the thing hitting the part is a player
	if player then
		--only give the sword to the player if they don't already have the sword
		if not player.Backpack:FindFirstChild(sword.Name) then
			--clone the sword from the replicated storage and give it to them
			local clonedSword = sword:Clone()
	
			--put the sword in the player's backpack
			clonedSword.Parent = player.Character.Backpack
		end
	end
end)


1 comment

1

why don't you use :GetPlayerFromCharacter. This is more reliable

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