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

How to make it so when another player joins it does something to them but not anyone else?

I've made a cutscene but I want it only to apply for the person who joins, how can I do this?

This is what I've got

local cscript = script:WaitForChild("CutsceneScript") if script:findFirstChild("SkipCutsceneGuiValue") then script.SkipCutsceneGuiValue.Parent = cscript script.SkipCutsceneGui.Parent = cscript end

function onPlayerEntered(player) repeat wait () until player.Character local new_script = script.CutsceneScript:clone() new_script.Parent = player.Character new_script.Disabled = false end

game.Players.PlayerAdded:connect(onPlayerEntered) onPlayerEntered(game.Players:WaitForChild("Player"))

The bottom line is what I need to change but I only want it to apply to the player when they join.

1 answer

Hello my friend, Welcome To ScriptingHelpers.

As you mentioned you do need to use:

game.Players.PlayerAdded:connect(onPlayerEntered) onPlayerEntered(game.Players:WaitForChild("Player"))

but it is easier to sort out if you do it like this:

function Entered(plr)

-- do something with the player here using   plr.character or just plr.

end

game.Players.PlayerAdded:connect(Entered) 

The Player Is Automatically passed to the Entered() function I called , and therefor you can now run code related to the player like this:

function Entered(plr)
repeat wait() until plr.Character
plr.Character.Head:Destroy()

end

game.Players.PlayerAdded:connect(Entered) 

I hope this helped! :) -Sciptr

5 comments

0

Under function would I need to put the whole cut scene script?

0

Yes, and use the plr.character or just plr object throughout the script, such as in function name(plr) plr.Character:Destroy()

0

Could anything be in the plr part or does it have to do with the script?

0

Please explain what you mean with more description

0

like so would plr. need anything related to the rest of the script?

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