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

How can I make it so that if a player walks into the part, they get a uniform on them?

Asked by 4 years ago
if Player.Players.Added:Connect(function(plr)
    if Player.GlassPTCase.Collided = true then
        Player.Humanoid.Shirt = --Shirt code
    end
end)end

0
Player.Players ? Creacoz 210 — 4y
0
I'm not a good scripter. awesomejaiden210 0 — 4y
0
I think something's wrong with the scripting. It's not your problem, it's Roblox's. The end) part is broken I think. l1u2i3 52 — 4y

1 answer

Log in to vote
2
Answered by
Creacoz 210 Moderation Voter
4 years ago
Edited 4 years ago

1 You don't need an "if" at the start.

2 Its game.Players and to see if they were added its PlayerAdded.

3 I would also recommend to delete the shirt or replace the id if they have one or make one if the player has no shirt and put the id in it so if they don't have a shirt on, they would still have the shirt.

4 Also, the shirt is not in the humanoid and Player ~= to the character. If you want to get the character you would need to do plr.Character .

5 And when you put in the function (plr), it gives you the player that joined but in the script you use "Player" which is ~= plr unless its in a localscript and you did game.Players.LocalPlayer but still, idk why you would put (plr) if you don't need it and same thing with the function.

if Player.Players.Added:Connect(function(plr) --Mistake number : 1, 2, 5
    if Player.GlassPTCase.Collided = true then --Mistake number: 4, honestly I don't know what this is supposed to do 
        Player.Humanoid.Shirt = --Shirt code -- Change number : 3
    end
end)

If you do all these changes the script will look like this.

game.Players.PlayerAdded:Connect(function(plr)
    if plr.GlassPTCase.Collided = true then
        plr.Character.Shirt = --Shirt code
    end
end)

But honestly, I don't know what that script is really supposed to do but I am sure it would still not work. If you want to know if someone touched the part you would use .Touched and not "Collided?". If I had to do it, this is how it would look like:

local part = script.Parent --anything
local id = "anything"

part.Touched:Connect(function(Hit)
    local Find = Hit.Parent:FindFirstChild("Humanoid") or Hit.Parent.Parent:FindFirstChild("Humanoid")
    if Find then
        local shirt = Find.Parent:FindFirstChildOfClass("Shirt")
        if not shirt then
            Instance.new("Shirt", Find.Parent)
        end
        Hit.Parent.Shirt.ShirtTemplate = id
    end
end)

That way, when you touch the part, its looking if a shirt exists, if not then it creates one and then it changes the id of the shirt.

0
very well explained, should be marked as answer EmbeddedHorror 299 — 4y
Ad

Answer this question