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

How to transform a touch block in a PlayerSpawn code?

Hello, i don't know how to transform this code:

function onTouched(hit) local d = hit.Parent:GetChildren() for i=1, #d do if (d[i].className == "Accessory") then d[i]:remove() end end end

script.Parent.Touched:connect(onTouched)

For when the player spawns, it execute.

1 answer

try this in a normal script in the workspace

local spawn = start spawn

local spawnfolder = Instance.new('Folder')
spawnfolder.Name = spawnfolder --put your spawns here
spawnfolder.Parent = workspace

for i,v in pairs(spawnfolder:GetChildren()) do
	if v:IsA('BasePart') then
		v.Touched:connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") and game.Players:FindFirstChild(hit.Parent.Name) then
				spawn = v.Name
			end
		end)
	end
end

game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
		char.HumanoidRootPart.CFrame = CFrame.new(spawnfolder:FindFirstChild(spawn).CFrame.x,spawnfolder:FindFirstChild(spawn).CFrame.y+3,spawnfolder:FindFirstChild(spawn).CFrame.z)
	end)
end)

i think this will work

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