Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Help with a script idea (?)

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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

Log in to vote
0
Answered by 8 years ago

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.

1
Dude, you gotta explain your answers. https://scriptinghelpers.org/help/how-post-good-questions-answers Perci1 4988 — 8y
0
Thank you for pointing out. ZarsBranchkin 885 — 8y
Ad

Answer this question