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

place something in StarterCharacterScripts HELP!?

Asked by
14dark14 167
4 years ago

ok so I made a custom hat and if i place it in StarterCharacterScripts it works and all good, but don't need the hat in there all the time. I was trying to clone it in from ServerStorage with scripts but that didn't work, then I was trying to clone it using server scripts, but that also didn't work can here is the script I made

( Server Script inside Server Script Service )

( Hat is located in ServerStorage)

( I want it to get cloned on the player )

character = game.Players.LocalPlayer
hat = game.ServerStorage.RBT
a = hat:Clone()
a.Parent = character

0
You can't get LocalPlayer from ServerScript. Maybe you should use PlayerAdded event which is have a Player instance. https://developer.roblox.com/api-reference/event/Players/PlayerAdded Block_manvn 395 — 4y

2 answers

Log in to vote
1
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You cannot call the local Player from a ServerScript, as it is designed to operate as a Server instruction and not a Client—meaning it doesn’t have a Player Object to link to. You cannot use a LocalScript in this situation either as it is unable to gain access to SeverStorage due to FE regulations. To solve your issue, use a .PlayerAdded event to clone to the Hat to each character and Player upon joining.

local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players”)

local Hat = ServerStorage:WaitForChild("RBT")

Players.PlayerAdded:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Character)
        Hat:Clone().Parent = Character 
    end)
end)
Ad
Log in to vote
0
Answered by 4 years ago

Try put the hat in ServerStorage. Use a local script in StarterPlayer > StarterPlayerScripts and make all of the objects a variable:

local char = game:GetService("Players").LocalPlayer local hat = game:GetService("ServerStorage").RBT local a = hat:Clone() a.Parent = char (and for the head if it is a hat do char.Head)

0
local script cant access server storage 14dark14 167 — 4y

Answer this question