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

Help with a script idea (?)

I do not know how to script a program that you detect if a player has been infected. What I mean infected is (Material of body: Neon; Color: Really red). Alsoooo, how do I clone an item into hit's backpack?

1 answer

Best would be to do whatever you want in same script that infects others, but if you have no other choice, this should work too:

-- This should be a regular script, as server would be most suitable for this kind of thing
local theTool = pathToInfectedTool

-- Since we want to manipulate with all players, let's just hook up to event for player joining
game.Players.PlayerAdded:connect(function( player )
	-- Since we care about character related events, it is a good idea to hook up the character spawning event too
	player.CharacterAdded:connect(function( char )
		-- Wait for the torso to appear, since it might not get added instantly
		local torso = char:WaitForChild( "Torso" )

		-- Now listen for torso changes, since that will hint you that the character has been infected
		torso.Changed:connect(function( property )
			-- Check if torso material has been changed to neon
			if property == "Material" and torso.Material == "Neon" then
				-- The person got infected
				-- Copy the tool to the player's backpack
				theTool:clone().Parent = player.Backpack
			end
		end)
	end)
end)

Someone is on downvote spree it seems.

2 comments

1
0

Thank you for pointing out.

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