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

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

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

✓ Accepted answer

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!

2 comments

0

thank you! :)

0

Can you accept my answer?

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)

1 comment

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)

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