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

How do you fetch the players name in a script (More context when clicked)?

Im making it so that theres a model in server storage and it has a script inside of it and what im trying to do with that script is that it gets a players name then gets the character then places the model in the players position. Then using another script that when clicked it will clone model and put in in workspace. This is the script which is in the model

local brickBlast = script.Parent

for i,v in pairs(game.Players:GetPlayers()) do

wait()


local player = v.Name


brickBlast.PrimaryPart = brickBlast.Center
brickBlast:SetPrimaryPartCFrame(CFrame.new(player.Character.HumanoidRootPart.Position))

end

1 answer

A little unsure about what you're exactly looking for but you can get the player and the character like this

-- runs every time a new player joins
game.Players.PlayerAdded:Connect(function(player)
	-- runs whenever the character spawns
	player.CharacterAdded:Connect(function(character)
		-- would be where next part goes
	end
end)

from that you can use this to move the model to the character. change BrickBlast to whatever your model is called

game.ServerStorage.BrickBlast:SetPrimaryPartCFrame(character.PrimaryPart.CFrame)

Also know that no scripts will run while inside server storage. This would go inside serverscriptservice.

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