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

Newbie and unsure on how localplayer works? need help learning!

Asked by 1 year ago
Edited 1 year ago

I don't know what I'm doing wrong but I can't get this code to work however I do it. Please help!

local player = game:GetService("Players").LocalPlayer.name
game:GetService("Workspace").player.Object:Destroy()

No I cannot do game:GetService("Workspace").localplayer

0
What exactly are you trying to achieve? xInfinityBear 1777 — 1y

1 answer

Log in to vote
0
Answered by
pwx 1581 Moderation Voter
1 year ago

By the looks of this code you're trying to destroy the player's character on the client?

local Players = game:GetService('Players')
local Player = Players.LocalPlayer

-- getting the character is the same as workspace:WaitForChild(Player.Name)
-- but it's a lot more easier and the preferred method 
local Character = Player.Character or Player.CharacterAdded:Wait()

Character:Destroy()
Ad

Answer this question