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

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

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

1 comment

0

What exactly are you trying to achieve?

1 answer

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()

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