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

How to transform a touch block in a PlayerSpawn code?

Asked by
Anubizx 76
6 years ago

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

Log in to vote
0
Answered by 6 years ago

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

Ad

Answer this question