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

Spawn color not changing with the script?

UserInputService = game:GetService("UserInputService")
local Spawn1 = game.Workspace.SpawnLocation

UserInputService.InputBegan:Connect(function(input, GameProcessedEvent)

local RandomEvent = math.random(1,5)
	if input.KeyCode == Enum.KeyCode.E and RandomEvent == 1 then
		Spawn1 = BrickColor.new("Really red")
	end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 2 then
	    Spawn1 = BrickColor.new("Baby blue")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 3 then
	    Spawn1 = BrickColor.new("Gold")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 4 then
	    Spawn1 = BrickColor.new("Grey")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 1 then
	    Spawn1 = BrickColor.new("Beige")
    end
end)

Someone could explain why it's not changing colors?

1 answer

Set the BrickColor of the spawn not the spawn as a BrickColor

UserInputService = game:GetService("UserInputService")
local Spawn1 = game.Workspace.SpawnLocation

UserInputService.InputBegan:Connect(function(input, GameProcessedEvent)

local RandomEvent = math.random(1,5)
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 1 then
        Spawn1.BrickColor = BrickColor.new("Really red")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 2 then
        Spawn1.BrickColor = BrickColor.new("Baby blue")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 3 then
        Spawn1.BrickColor= BrickColor.new("Gold")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 4 then
        Spawn1.BrickColor = BrickColor.new("Grey")
    end
    if input.KeyCode == Enum.KeyCode.E and RandomEvent == 1 then
        Spawn1.BrickColor = BrickColor.new("Beige")
    end
end)

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