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

How to identify the player?

yee me dumb and a bad scripter so i have this script and i want it to have every player in the game be affected by it local currentValue = player.PlayerStats.CurrentValue;

currentValue.Changed:Connect(function(newValue)

if (newValue >= 20) then

player.Character.Humanoid.JumpPower = 100;

end

end); how do i do that so with the player part like local player = ? what do i do

1 answer

✓ Accepted answer

Hello there dear user,

This question is quite simple to answer, but I'll give you both Server Side and Client Side answers!

Client Side:

local plr = game.Players.LocalPlayer
local char
repeat wait() until plr.Character ~= nil
char = plr.Character -- character is now not nil
-- now you can do anything you want!

Server Side

local Players = game:GetService('Players')
local AddedEvent = Players.PlayerAdded
local Func1 = AddedEvent:Connect(function(plr) -- identify it as func1 so you can :Disconnect it!
    wait(0.1) -- useful ( do not remove )
    local char
    plr.CharacterAdded:Connect(function(newchar)
	    char = newchar -- new character
	    -- new character declaration SAME CODE HERE
	end)
	char = plr.Character
	-- do anything to the character UNDER THIS LINE
end)

Now that you understand the Basics of what this is, you can now continue doing what you enjoy.

3 comments

0

thanks

0

Why did you repeat wait() until plr.Character?

0

so when u want to use the Character , it doesn't cause an Error like "Character Not Found or NIL" something like that..

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