#LocalScript in StarterCharacter or StarterPlayer never execute

1 messages · Page 1 of 1 (latest)

coral notch
#

image of code working on studio mode

woven citrus
#

must be an outdated version, it would work if there was no problem

frail heron
#
local Players = game:GetService("Players") -- Make sure to use :GetService() if you're not already

local player = Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()

player.CharacterAdded:Connect(function(newChar)
    char = newChar
end)
woven citrus
#

LocalPlayer always exists from the client's perspective, so. Since it's a character script you can just say script.Parent

frail heron
#

yeah, might be best if it's a character script, I know it can be funny sometimes if the script is put inside the character

coral notch
#

ill try out all of these, thank you

coral notch
#

weirdly none of these worked. idk if its roblox itself but ill try more options

woven citrus
#

script will always have a parent or it can't execute

coral notch
#

ill try to parent it to starterplayer

formal spade
#

game.Players.LocalPlayer

#

You forgot the game

opal pilot
#

One message removed from a suspended account.

formal spade
#

maybe players is not getting set correctly

#

and its a empty table

#

so player.localplayer = nil

#

if players is a table then it wont give a error

opal pilot
#

One message removed from a suspended account.

coral notch
#

update:
in my script i was defining player so i could get the mouse position. i realized that theres a different method of getting the mouse position and expected the code to run normally, but when i tested in roblox player again, nothing would work. only in studio mode. maybe this is just some weird bug

#

LocalScript in StarterCharacter never executes

#

LocalScript in StarterCharacter or StarterPlayer never execute