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

How to identify the player?

Asked by 5 years ago

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

Log in to vote
1
Answered by 5 years ago

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.

0
thanks MPforfun 91 — 5y
0
Why did you repeat wait() until plr.Character? User#24403 69 — 5y
0
so when u want to use the Character , it doesn't cause an Error like "Character Not Found or NIL" something like that.. Danielkaya 58 — 5y
Ad

Answer this question