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

how would I make a decal change to another decal when a certain team clicks it?

Asked by 6 years ago
Edited 6 years ago

I'm making a jeopardy game but I have no idea how to script so how would I make a decal change when a team called "host" clicks it?

I haven't tried anything cause idk where to start or where to put the script.

Would this be the right code?

PartContainingDecal.ClickDetector.MouseClick:connect(function(PlayerWhoClicked)
    if PlayerWhoClicked.Team.Name == "TeamName" then
        PartContainingDecal.Decal.DecalId = id 
    end 
end)

2 answers

Log in to vote
0
Answered by
Leamir 3138 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

Hello, Innovation_dev!

Your script should be something like this one:

local TeamName = "Host" -- Change the team color to the correct one!
local PartContainingDecal = script.Parent -- Change the part containing decal to the correct one!
local id = 0000000 -- Change the decal id to the correct one!

PartContainingDecal.ClickDetector.MouseClick:connect(function(PlayerWhoClicked)
    for _,teamMember in pairs(game.Teams[TeamName]:GetPlayers()) do
        if PlayerWhoClicked.Name == teamMember then
            PartContainingDecal:FindFirstChild("Decal").DecalId = id 
        end
    end 
end)

Good Luck with your games!

0
thank you! :) Innovation_dev 2 — 6y
0
Can you accept my answer? Leamir 3138 — 6y
Ad
Log in to vote
-1
Answered by
G_han 3
6 years ago

Hi Innovation_dev, I don't know if I am 100% correct, but I am pretty sure clickdetectors dont work with decals. Something you can do is use a part that holds the decal, so you can use the part as what you would click. Here is a sample code of what you can do:

local team = INSERT_TEAM_STUFF
local part = workspace.PartWithDecal
local partClickDetector = part.ClickDetector
partClickDetector.MouseClick:Connect(function(player)
    if player.Team == team then
        part.Decal.DecalId = id
    end
end)
0
G_han, you can't test for teams by its name, you have to use a script like mine to get team members(Line 6) Leamir 3138 — 6y

Answer this question