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)
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!
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)