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

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

Asked by 9 years ago

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

Log in to vote
0
Answered by
Sciptr 5
9 years ago

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

0
Under function would I need to put the whole cut scene script? badasszombie115 0 — 9y
0
Yes, and use the plr.character or just plr object throughout the script, such as in function name(plr) plr.Character:Destroy() Sciptr 5 — 9y
0
Could anything be in the plr part or does it have to do with the script? badasszombie115 0 — 9y
0
Please explain what you mean with more description Sciptr 5 — 9y
0
like so would plr. need anything related to the rest of the script? badasszombie115 0 — 9y
Ad

Answer this question